Commit 8249d084 authored by Kieran Bingham's avatar Kieran Bingham Committed by Hans Verkuil

media: imx335: Support 2 or 4 lane operation modes

The IMX335 can support both 2 and 4 lane configurations.
Extend the driver to configure the lane mode accordingly.
Update the pixel rate depending on the number of lanes in use.
Signed-off-by: default avatarKieran Bingham <kieran.bingham@ideasonboard.com>
Signed-off-by: default avatarUmang Jain <umang.jain@ideasonboard.com>
Reviewed-by: default avatarTommaso Merciai <tomm.merciai@gmail.com>
Signed-off-by: default avatarSakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: default avatarHans Verkuil <hverkuil-cisco@xs4all.nl>
[hverkuil: fixup missing : in @lane_mode kerneldoc line]
parent d9134bd7
...@@ -21,6 +21,11 @@ ...@@ -21,6 +21,11 @@
#define IMX335_MODE_STANDBY 0x01 #define IMX335_MODE_STANDBY 0x01
#define IMX335_MODE_STREAMING 0x00 #define IMX335_MODE_STREAMING 0x00
/* Data Lanes */
#define IMX335_LANEMODE 0x3a01
#define IMX335_2LANE 1
#define IMX335_4LANE 3
/* Lines per frame */ /* Lines per frame */
#define IMX335_REG_LPFR 0x3030 #define IMX335_REG_LPFR 0x3030
...@@ -147,6 +152,7 @@ struct imx335_mode { ...@@ -147,6 +152,7 @@ struct imx335_mode {
* @exp_ctrl: Pointer to exposure control * @exp_ctrl: Pointer to exposure control
* @again_ctrl: Pointer to analog gain control * @again_ctrl: Pointer to analog gain control
* @vblank: Vertical blanking in lines * @vblank: Vertical blanking in lines
* @lane_mode: Mode for number of connected data lanes
* @cur_mode: Pointer to current selected sensor mode * @cur_mode: Pointer to current selected sensor mode
* @mutex: Mutex for serializing sensor controls * @mutex: Mutex for serializing sensor controls
* @link_freq_bitmap: Menu bitmap for link_freq_ctrl * @link_freq_bitmap: Menu bitmap for link_freq_ctrl
...@@ -171,6 +177,7 @@ struct imx335 { ...@@ -171,6 +177,7 @@ struct imx335 {
struct v4l2_ctrl *again_ctrl; struct v4l2_ctrl *again_ctrl;
}; };
u32 vblank; u32 vblank;
u32 lane_mode;
const struct imx335_mode *cur_mode; const struct imx335_mode *cur_mode;
struct mutex mutex; struct mutex mutex;
unsigned long link_freq_bitmap; unsigned long link_freq_bitmap;
...@@ -936,6 +943,11 @@ static int imx335_start_streaming(struct imx335 *imx335) ...@@ -936,6 +943,11 @@ static int imx335_start_streaming(struct imx335 *imx335)
return ret; return ret;
} }
/* Configure lanes */
ret = imx335_write_reg(imx335, IMX335_LANEMODE, 1, imx335->lane_mode);
if (ret)
return ret;
/* Setup handler will write actual exposure and gain */ /* Setup handler will write actual exposure and gain */
ret = __v4l2_ctrl_handler_setup(imx335->sd.ctrl_handler); ret = __v4l2_ctrl_handler_setup(imx335->sd.ctrl_handler);
if (ret) { if (ret) {
...@@ -1096,7 +1108,14 @@ static int imx335_parse_hw_config(struct imx335 *imx335) ...@@ -1096,7 +1108,14 @@ static int imx335_parse_hw_config(struct imx335 *imx335)
if (ret) if (ret)
return ret; return ret;
if (bus_cfg.bus.mipi_csi2.num_data_lanes != IMX335_NUM_DATA_LANES) { switch (bus_cfg.bus.mipi_csi2.num_data_lanes) {
case 2:
imx335->lane_mode = IMX335_2LANE;
break;
case 4:
imx335->lane_mode = IMX335_4LANE;
break;
default:
dev_err(imx335->dev, dev_err(imx335->dev,
"number of CSI2 data lanes %d is not supported\n", "number of CSI2 data lanes %d is not supported\n",
bus_cfg.bus.mipi_csi2.num_data_lanes); bus_cfg.bus.mipi_csi2.num_data_lanes);
......
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