Skip to content

Commit 34f9eff

Browse files
jwrdegoedemchehab
authored andcommitted
media: ov2680: Add link-freq and pixel-rate controls
Add read-only link-freq and pixel-rate controls. This is necessary for the sensor to work with the ipu3-cio2 driver and for libcamera. Acked-by: Rui Miguel Silva <[email protected]> Signed-off-by: Hans de Goede <[email protected]> Signed-off-by: Sakari Ailus <[email protected]> Signed-off-by: Mauro Carvalho Chehab <[email protected]>
1 parent a99a041 commit 34f9eff

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

drivers/media/i2c/ov2680.c

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,12 @@
7575
#define OV2680_MIN_CROP_WIDTH 2
7676
#define OV2680_MIN_CROP_HEIGHT 2
7777

78+
/* Fixed pre-div of 1/2 */
79+
#define OV2680_PLL_PREDIV0 2
80+
81+
/* Pre-div configurable through reg 0x3080, left at its default of 0x02 : 1/2 */
82+
#define OV2680_PLL_PREDIV 2
83+
7884
/* 66MHz pixel clock: 66MHz / 1704 * 1294 = 30fps */
7985
#define OV2680_PIXELS_PER_LINE 1704
8086
#define OV2680_LINES_PER_FRAME 1294
@@ -121,6 +127,8 @@ struct ov2680_ctrls {
121127
struct v4l2_ctrl *hflip;
122128
struct v4l2_ctrl *vflip;
123129
struct v4l2_ctrl *test_pattern;
130+
struct v4l2_ctrl *link_freq;
131+
struct v4l2_ctrl *pixel_rate;
124132
};
125133

126134
struct ov2680_mode {
@@ -147,6 +155,8 @@ struct ov2680_dev {
147155
struct clk *xvclk;
148156
u32 xvclk_freq;
149157
u8 pll_mult;
158+
s64 link_freq[1];
159+
u64 pixel_rate;
150160
struct regulator_bulk_data supplies[OV2680_NUM_SUPPLIES];
151161

152162
struct gpio_desc *pwdn_gpio;
@@ -931,13 +941,20 @@ static int ov2680_v4l2_register(struct ov2680_dev *sensor)
931941
ctrls->gain = v4l2_ctrl_new_std(hdl, ops, V4L2_CID_ANALOGUE_GAIN,
932942
0, 1023, 1, 250);
933943

944+
ctrls->link_freq = v4l2_ctrl_new_int_menu(hdl, NULL, V4L2_CID_LINK_FREQ,
945+
0, 0, sensor->link_freq);
946+
ctrls->pixel_rate = v4l2_ctrl_new_std(hdl, NULL, V4L2_CID_PIXEL_RATE,
947+
0, sensor->pixel_rate,
948+
1, sensor->pixel_rate);
949+
934950
if (hdl->error) {
935951
ret = hdl->error;
936952
goto cleanup_entity;
937953
}
938954

939955
ctrls->vflip->flags |= V4L2_CTRL_FLAG_MODIFY_LAYOUT;
940956
ctrls->hflip->flags |= V4L2_CTRL_FLAG_MODIFY_LAYOUT;
957+
ctrls->link_freq->flags |= V4L2_CTRL_FLAG_READ_ONLY;
941958

942959
sensor->sd.ctrl_handler = hdl;
943960

@@ -1067,6 +1084,13 @@ static int ov2680_parse_dt(struct ov2680_dev *sensor)
10671084

10681085
sensor->pll_mult = ov2680_pll_multipliers[i];
10691086

1087+
sensor->link_freq[0] = sensor->xvclk_freq / OV2680_PLL_PREDIV0 /
1088+
OV2680_PLL_PREDIV * sensor->pll_mult;
1089+
1090+
/* CSI-2 is double data rate, bus-format is 10 bpp */
1091+
sensor->pixel_rate = sensor->link_freq[0] * 2;
1092+
do_div(sensor->pixel_rate, 10);
1093+
10701094
return 0;
10711095
}
10721096

0 commit comments

Comments
 (0)