Commit 995809ce authored by Dave Stevenson's avatar Dave Stevenson Committed by Mauro Carvalho Chehab

media: i2c: ov9282: Support more than 1 mode.

The driver currently has multiple assumptions that there is
only one supported mode.

Convert supported_mode to an array, and fix up all references
to correctly look at that array.
Signed-off-by: default avatarDave Stevenson <dave.stevenson@raspberrypi.com>
Reviewed-by: default avatarJacopo Mondi <jacopo@jmondi.org>
Signed-off-by: default avatarSakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@kernel.org>
parent f15b0612
...@@ -217,6 +217,10 @@ struct ov9282_reg_list common_regs_list = { ...@@ -217,6 +217,10 @@ struct ov9282_reg_list common_regs_list = {
.regs = common_regs, .regs = common_regs,
}; };
#define MODE_1280_720 0
#define DEFAULT_MODE MODE_1280_720
/* Sensor mode registers */ /* Sensor mode registers */
static const struct ov9282_reg mode_1280x720_regs[] = { static const struct ov9282_reg mode_1280x720_regs[] = {
{0x3778, 0x00}, {0x3778, 0x00},
...@@ -252,17 +256,19 @@ static const struct ov9282_reg mode_1280x720_regs[] = { ...@@ -252,17 +256,19 @@ static const struct ov9282_reg mode_1280x720_regs[] = {
}; };
/* Supported sensor mode configurations */ /* Supported sensor mode configurations */
static const struct ov9282_mode supported_mode = { static const struct ov9282_mode supported_modes[] = {
.width = 1280, [MODE_1280_720] = {
.height = 720, .width = 1280,
.hblank = 250, .height = 720,
.vblank = 1022, .hblank = 250,
.vblank_min = 151, .vblank = 1022,
.vblank_max = 51540, .vblank_min = 151,
.link_freq_idx = 0, .vblank_max = 51540,
.reg_list = { .link_freq_idx = 0,
.num_of_regs = ARRAY_SIZE(mode_1280x720_regs), .reg_list = {
.regs = mode_1280x720_regs, .num_of_regs = ARRAY_SIZE(mode_1280x720_regs),
.regs = mode_1280x720_regs,
},
}, },
}; };
...@@ -526,15 +532,15 @@ static int ov9282_enum_frame_size(struct v4l2_subdev *sd, ...@@ -526,15 +532,15 @@ static int ov9282_enum_frame_size(struct v4l2_subdev *sd,
struct v4l2_subdev_state *sd_state, struct v4l2_subdev_state *sd_state,
struct v4l2_subdev_frame_size_enum *fsize) struct v4l2_subdev_frame_size_enum *fsize)
{ {
if (fsize->index > 0) if (fsize->index >= ARRAY_SIZE(supported_modes))
return -EINVAL; return -EINVAL;
if (fsize->code != MEDIA_BUS_FMT_Y10_1X10) if (fsize->code != MEDIA_BUS_FMT_Y10_1X10)
return -EINVAL; return -EINVAL;
fsize->min_width = supported_mode.width; fsize->min_width = supported_modes[fsize->index].width;
fsize->max_width = fsize->min_width; fsize->max_width = fsize->min_width;
fsize->min_height = supported_mode.height; fsize->min_height = supported_modes[fsize->index].height;
fsize->max_height = fsize->min_height; fsize->max_height = fsize->min_height;
return 0; return 0;
...@@ -609,7 +615,11 @@ static int ov9282_set_pad_format(struct v4l2_subdev *sd, ...@@ -609,7 +615,11 @@ static int ov9282_set_pad_format(struct v4l2_subdev *sd,
mutex_lock(&ov9282->mutex); mutex_lock(&ov9282->mutex);
mode = &supported_mode; mode = v4l2_find_nearest_size(supported_modes,
ARRAY_SIZE(supported_modes),
width, height,
fmt->format.width,
fmt->format.height);
ov9282_fill_pad_format(ov9282, mode, fmt); ov9282_fill_pad_format(ov9282, mode, fmt);
if (fmt->which == V4L2_SUBDEV_FORMAT_TRY) { if (fmt->which == V4L2_SUBDEV_FORMAT_TRY) {
...@@ -642,7 +652,7 @@ static int ov9282_init_pad_cfg(struct v4l2_subdev *sd, ...@@ -642,7 +652,7 @@ static int ov9282_init_pad_cfg(struct v4l2_subdev *sd,
struct v4l2_subdev_format fmt = { 0 }; struct v4l2_subdev_format fmt = { 0 };
fmt.which = sd_state ? V4L2_SUBDEV_FORMAT_TRY : V4L2_SUBDEV_FORMAT_ACTIVE; fmt.which = sd_state ? V4L2_SUBDEV_FORMAT_TRY : V4L2_SUBDEV_FORMAT_ACTIVE;
ov9282_fill_pad_format(ov9282, &supported_mode, &fmt); ov9282_fill_pad_format(ov9282, &supported_modes[DEFAULT_MODE], &fmt);
return ov9282_set_pad_format(sd, sd_state, &fmt); return ov9282_set_pad_format(sd, sd_state, &fmt);
} }
...@@ -1043,8 +1053,8 @@ static int ov9282_probe(struct i2c_client *client) ...@@ -1043,8 +1053,8 @@ static int ov9282_probe(struct i2c_client *client)
goto error_power_off; goto error_power_off;
} }
/* Set default mode to max resolution */ /* Set default mode to first mode */
ov9282->cur_mode = &supported_mode; ov9282->cur_mode = &supported_modes[DEFAULT_MODE];
ov9282->vblank = ov9282->cur_mode->vblank; ov9282->vblank = ov9282->cur_mode->vblank;
ret = ov9282_init_controls(ov9282); ret = ov9282_init_controls(ov9282);
......
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