Commit f0cd015e authored by Hans Verkuil's avatar Hans Verkuil Committed by Mauro Carvalho Chehab

[media] tvp7002: replace 'preset' by 'timings' in various structs/variables

This is the first step towards removing the deprecated preset support of this
driver.
Signed-off-by: default avatarHans Verkuil <hans.verkuil@cisco.com>
Acked-by: default avatarLad, Prabhakar <prabhakar.lad@ti.com>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@redhat.com>
parent f08e9f0d
...@@ -326,8 +326,8 @@ static const struct i2c_reg_value tvp7002_parms_720P50[] = { ...@@ -326,8 +326,8 @@ static const struct i2c_reg_value tvp7002_parms_720P50[] = {
{ TVP7002_EOR, 0xff, TVP7002_RESERVED } { TVP7002_EOR, 0xff, TVP7002_RESERVED }
}; };
/* Preset definition for handling device operation */ /* Timings definition for handling device operation */
struct tvp7002_preset_definition { struct tvp7002_timings_definition {
u32 preset; u32 preset;
struct v4l2_dv_timings timings; struct v4l2_dv_timings timings;
const struct i2c_reg_value *p_settings; const struct i2c_reg_value *p_settings;
...@@ -339,8 +339,8 @@ struct tvp7002_preset_definition { ...@@ -339,8 +339,8 @@ struct tvp7002_preset_definition {
u16 cpl_max; u16 cpl_max;
}; };
/* Struct list for digital video presets */ /* Struct list for digital video timings */
static const struct tvp7002_preset_definition tvp7002_presets[] = { static const struct tvp7002_timings_definition tvp7002_timings[] = {
{ {
V4L2_DV_720P60, V4L2_DV_720P60,
V4L2_DV_BT_CEA_1280X720P60, V4L2_DV_BT_CEA_1280X720P60,
...@@ -420,7 +420,7 @@ static const struct tvp7002_preset_definition tvp7002_presets[] = { ...@@ -420,7 +420,7 @@ static const struct tvp7002_preset_definition tvp7002_presets[] = {
} }
}; };
#define NUM_PRESETS ARRAY_SIZE(tvp7002_presets) #define NUM_TIMINGS ARRAY_SIZE(tvp7002_timings)
/* Device definition */ /* Device definition */
struct tvp7002 { struct tvp7002 {
...@@ -431,7 +431,7 @@ struct tvp7002 { ...@@ -431,7 +431,7 @@ struct tvp7002 {
int ver; int ver;
int streaming; int streaming;
const struct tvp7002_preset_definition *current_preset; const struct tvp7002_timings_definition *current_timings;
}; };
/* /*
...@@ -603,11 +603,11 @@ static int tvp7002_s_dv_preset(struct v4l2_subdev *sd, ...@@ -603,11 +603,11 @@ static int tvp7002_s_dv_preset(struct v4l2_subdev *sd,
u32 preset; u32 preset;
int i; int i;
for (i = 0; i < NUM_PRESETS; i++) { for (i = 0; i < NUM_TIMINGS; i++) {
preset = tvp7002_presets[i].preset; preset = tvp7002_timings[i].preset;
if (preset == dv_preset->preset) { if (preset == dv_preset->preset) {
device->current_preset = &tvp7002_presets[i]; device->current_timings = &tvp7002_timings[i];
return tvp7002_write_inittab(sd, tvp7002_presets[i].p_settings); return tvp7002_write_inittab(sd, tvp7002_timings[i].p_settings);
} }
} }
...@@ -623,12 +623,12 @@ static int tvp7002_s_dv_timings(struct v4l2_subdev *sd, ...@@ -623,12 +623,12 @@ static int tvp7002_s_dv_timings(struct v4l2_subdev *sd,
if (dv_timings->type != V4L2_DV_BT_656_1120) if (dv_timings->type != V4L2_DV_BT_656_1120)
return -EINVAL; return -EINVAL;
for (i = 0; i < NUM_PRESETS; i++) { for (i = 0; i < NUM_TIMINGS; i++) {
const struct v4l2_bt_timings *t = &tvp7002_presets[i].timings.bt; const struct v4l2_bt_timings *t = &tvp7002_timings[i].timings.bt;
if (!memcmp(bt, t, &bt->standards - &bt->width)) { if (!memcmp(bt, t, &bt->standards - &bt->width)) {
device->current_preset = &tvp7002_presets[i]; device->current_timings = &tvp7002_timings[i];
return tvp7002_write_inittab(sd, tvp7002_presets[i].p_settings); return tvp7002_write_inittab(sd, tvp7002_timings[i].p_settings);
} }
} }
return -EINVAL; return -EINVAL;
...@@ -639,7 +639,7 @@ static int tvp7002_g_dv_timings(struct v4l2_subdev *sd, ...@@ -639,7 +639,7 @@ static int tvp7002_g_dv_timings(struct v4l2_subdev *sd,
{ {
struct tvp7002 *device = to_tvp7002(sd); struct tvp7002 *device = to_tvp7002(sd);
*dv_timings = device->current_preset->timings; *dv_timings = device->current_timings->timings;
return 0; return 0;
} }
...@@ -681,15 +681,15 @@ static int tvp7002_mbus_fmt(struct v4l2_subdev *sd, struct v4l2_mbus_framefmt *f ...@@ -681,15 +681,15 @@ static int tvp7002_mbus_fmt(struct v4l2_subdev *sd, struct v4l2_mbus_framefmt *f
int error; int error;
/* Calculate height and width based on current standard */ /* Calculate height and width based on current standard */
error = v4l_fill_dv_preset_info(device->current_preset->preset, &e_preset); error = v4l_fill_dv_preset_info(device->current_timings->preset, &e_preset);
if (error) if (error)
return error; return error;
f->width = e_preset.width; f->width = e_preset.width;
f->height = e_preset.height; f->height = e_preset.height;
f->code = V4L2_MBUS_FMT_YUYV10_1X20; f->code = V4L2_MBUS_FMT_YUYV10_1X20;
f->field = device->current_preset->scanmode; f->field = device->current_timings->scanmode;
f->colorspace = device->current_preset->color_space; f->colorspace = device->current_timings->color_space;
v4l2_dbg(1, debug, sd, "MBUS_FMT: Width - %d, Height - %d", v4l2_dbg(1, debug, sd, "MBUS_FMT: Width - %d, Height - %d",
f->width, f->height); f->width, f->height);
...@@ -697,16 +697,16 @@ static int tvp7002_mbus_fmt(struct v4l2_subdev *sd, struct v4l2_mbus_framefmt *f ...@@ -697,16 +697,16 @@ static int tvp7002_mbus_fmt(struct v4l2_subdev *sd, struct v4l2_mbus_framefmt *f
} }
/* /*
* tvp7002_query_dv_preset() - query DV preset * tvp7002_query_dv() - query DV timings
* @sd: pointer to standard V4L2 sub-device structure * @sd: pointer to standard V4L2 sub-device structure
* @qpreset: standard V4L2 v4l2_dv_preset structure * @index: index into the tvp7002_timings array
* *
* Returns the current DV preset by TVP7002. If no active input is * Returns the current DV timings detected by TVP7002. If no active input is
* detected, returns -EINVAL * detected, returns -EINVAL
*/ */
static int tvp7002_query_dv(struct v4l2_subdev *sd, int *index) static int tvp7002_query_dv(struct v4l2_subdev *sd, int *index)
{ {
const struct tvp7002_preset_definition *presets = tvp7002_presets; const struct tvp7002_timings_definition *timings = tvp7002_timings;
u8 progressive; u8 progressive;
u32 lpfr; u32 lpfr;
u32 cpln; u32 cpln;
...@@ -717,7 +717,7 @@ static int tvp7002_query_dv(struct v4l2_subdev *sd, int *index) ...@@ -717,7 +717,7 @@ static int tvp7002_query_dv(struct v4l2_subdev *sd, int *index)
u8 cpl_msb; u8 cpl_msb;
/* Return invalid index if no active input is detected */ /* Return invalid index if no active input is detected */
*index = NUM_PRESETS; *index = NUM_TIMINGS;
/* Read standards from device registers */ /* Read standards from device registers */
tvp7002_read_err(sd, TVP7002_L_FRAME_STAT_LSBS, &lpf_lsb, &error); tvp7002_read_err(sd, TVP7002_L_FRAME_STAT_LSBS, &lpf_lsb, &error);
...@@ -738,23 +738,23 @@ static int tvp7002_query_dv(struct v4l2_subdev *sd, int *index) ...@@ -738,23 +738,23 @@ static int tvp7002_query_dv(struct v4l2_subdev *sd, int *index)
progressive = (lpf_msb & TVP7002_INPR_MASK) >> TVP7002_IP_SHIFT; progressive = (lpf_msb & TVP7002_INPR_MASK) >> TVP7002_IP_SHIFT;
/* Do checking of video modes */ /* Do checking of video modes */
for (*index = 0; *index < NUM_PRESETS; (*index)++, presets++) for (*index = 0; *index < NUM_TIMINGS; (*index)++, timings++)
if (lpfr == presets->lines_per_frame && if (lpfr == timings->lines_per_frame &&
progressive == presets->progressive) { progressive == timings->progressive) {
if (presets->cpl_min == 0xffff) if (timings->cpl_min == 0xffff)
break; break;
if (cpln >= presets->cpl_min && cpln <= presets->cpl_max) if (cpln >= timings->cpl_min && cpln <= timings->cpl_max)
break; break;
} }
if (*index == NUM_PRESETS) { if (*index == NUM_TIMINGS) {
v4l2_dbg(1, debug, sd, "detection failed: lpf = %x, cpl = %x\n", v4l2_dbg(1, debug, sd, "detection failed: lpf = %x, cpl = %x\n",
lpfr, cpln); lpfr, cpln);
return -ENOLINK; return -ENOLINK;
} }
/* Update lines per frame and clocks per line info */ /* Update lines per frame and clocks per line info */
v4l2_dbg(1, debug, sd, "detected preset: %d\n", *index); v4l2_dbg(1, debug, sd, "detected timings: %d\n", *index);
return 0; return 0;
} }
...@@ -764,13 +764,13 @@ static int tvp7002_query_dv_preset(struct v4l2_subdev *sd, ...@@ -764,13 +764,13 @@ static int tvp7002_query_dv_preset(struct v4l2_subdev *sd,
int index; int index;
int err = tvp7002_query_dv(sd, &index); int err = tvp7002_query_dv(sd, &index);
if (err || index == NUM_PRESETS) { if (err || index == NUM_TIMINGS) {
qpreset->preset = V4L2_DV_INVALID; qpreset->preset = V4L2_DV_INVALID;
if (err == -ENOLINK) if (err == -ENOLINK)
err = 0; err = 0;
return err; return err;
} }
qpreset->preset = tvp7002_presets[index].preset; qpreset->preset = tvp7002_timings[index].preset;
return 0; return 0;
} }
...@@ -782,7 +782,7 @@ static int tvp7002_query_dv_timings(struct v4l2_subdev *sd, ...@@ -782,7 +782,7 @@ static int tvp7002_query_dv_timings(struct v4l2_subdev *sd,
if (err) if (err)
return err; return err;
*timings = tvp7002_presets[index].timings; *timings = tvp7002_timings[index].timings;
return 0; return 0;
} }
...@@ -896,7 +896,7 @@ static int tvp7002_s_stream(struct v4l2_subdev *sd, int enable) ...@@ -896,7 +896,7 @@ static int tvp7002_s_stream(struct v4l2_subdev *sd, int enable)
*/ */
static int tvp7002_log_status(struct v4l2_subdev *sd) static int tvp7002_log_status(struct v4l2_subdev *sd)
{ {
const struct tvp7002_preset_definition *presets = tvp7002_presets; const struct tvp7002_timings_definition *timings = tvp7002_timings;
struct tvp7002 *device = to_tvp7002(sd); struct tvp7002 *device = to_tvp7002(sd);
struct v4l2_dv_enum_preset e_preset; struct v4l2_dv_enum_preset e_preset;
struct v4l2_dv_preset detected; struct v4l2_dv_preset detected;
...@@ -907,20 +907,20 @@ static int tvp7002_log_status(struct v4l2_subdev *sd) ...@@ -907,20 +907,20 @@ static int tvp7002_log_status(struct v4l2_subdev *sd)
tvp7002_query_dv_preset(sd, &detected); tvp7002_query_dv_preset(sd, &detected);
/* Print standard related code values */ /* Print standard related code values */
for (i = 0; i < NUM_PRESETS; i++, presets++) for (i = 0; i < NUM_TIMINGS; i++, timings++)
if (presets->preset == detected.preset) if (timings->preset == detected.preset)
break; break;
if (v4l_fill_dv_preset_info(device->current_preset->preset, &e_preset)) if (v4l_fill_dv_preset_info(device->current_timings->preset, &e_preset))
return -EINVAL; return -EINVAL;
v4l2_info(sd, "Selected DV Preset: %s\n", e_preset.name); v4l2_info(sd, "Selected DV Preset: %s\n", e_preset.name);
v4l2_info(sd, " Pixels per line: %u\n", e_preset.width); v4l2_info(sd, " Pixels per line: %u\n", e_preset.width);
v4l2_info(sd, " Lines per frame: %u\n\n", e_preset.height); v4l2_info(sd, " Lines per frame: %u\n\n", e_preset.height);
if (i == NUM_PRESETS) { if (i == NUM_TIMINGS) {
v4l2_info(sd, "Detected DV Preset: None\n"); v4l2_info(sd, "Detected DV Preset: None\n");
} else { } else {
if (v4l_fill_dv_preset_info(presets->preset, &e_preset)) if (v4l_fill_dv_preset_info(timings->preset, &e_preset))
return -EINVAL; return -EINVAL;
v4l2_info(sd, "Detected DV Preset: %s\n", e_preset.name); v4l2_info(sd, "Detected DV Preset: %s\n", e_preset.name);
v4l2_info(sd, " Pixels per line: %u\n", e_preset.width); v4l2_info(sd, " Pixels per line: %u\n", e_preset.width);
...@@ -946,20 +946,20 @@ static int tvp7002_enum_dv_presets(struct v4l2_subdev *sd, ...@@ -946,20 +946,20 @@ static int tvp7002_enum_dv_presets(struct v4l2_subdev *sd,
struct v4l2_dv_enum_preset *preset) struct v4l2_dv_enum_preset *preset)
{ {
/* Check requested format index is within range */ /* Check requested format index is within range */
if (preset->index >= NUM_PRESETS) if (preset->index >= NUM_TIMINGS)
return -EINVAL; return -EINVAL;
return v4l_fill_dv_preset_info(tvp7002_presets[preset->index].preset, preset); return v4l_fill_dv_preset_info(tvp7002_timings[preset->index].preset, preset);
} }
static int tvp7002_enum_dv_timings(struct v4l2_subdev *sd, static int tvp7002_enum_dv_timings(struct v4l2_subdev *sd,
struct v4l2_enum_dv_timings *timings) struct v4l2_enum_dv_timings *timings)
{ {
/* Check requested format index is within range */ /* Check requested format index is within range */
if (timings->index >= NUM_PRESETS) if (timings->index >= NUM_TIMINGS)
return -EINVAL; return -EINVAL;
timings->timings = tvp7002_presets[timings->index].timings; timings->timings = tvp7002_timings[timings->index].timings;
return 0; return 0;
} }
...@@ -1043,7 +1043,7 @@ static int tvp7002_probe(struct i2c_client *c, const struct i2c_device_id *id) ...@@ -1043,7 +1043,7 @@ static int tvp7002_probe(struct i2c_client *c, const struct i2c_device_id *id)
sd = &device->sd; sd = &device->sd;
device->pdata = c->dev.platform_data; device->pdata = c->dev.platform_data;
device->current_preset = tvp7002_presets; device->current_timings = tvp7002_timings;
/* Tell v4l2 the device is ready */ /* Tell v4l2 the device is ready */
v4l2_i2c_subdev_init(sd, c, &tvp7002_ops); v4l2_i2c_subdev_init(sd, c, &tvp7002_ops);
...@@ -1080,7 +1080,7 @@ static int tvp7002_probe(struct i2c_client *c, const struct i2c_device_id *id) ...@@ -1080,7 +1080,7 @@ static int tvp7002_probe(struct i2c_client *c, const struct i2c_device_id *id)
return error; return error;
/* Set registers according to default video mode */ /* Set registers according to default video mode */
preset.preset = device->current_preset->preset; preset.preset = device->current_timings->preset;
error = tvp7002_s_dv_preset(sd, &preset); error = tvp7002_s_dv_preset(sd, &preset);
v4l2_ctrl_handler_init(&device->hdl, 1); v4l2_ctrl_handler_init(&device->hdl, 1);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment