49
49
#define IMX335_INCLK_RATE 24000000
50
50
51
51
/* CSI2 HW configuration */
52
- #define IMX335_LINK_FREQ 594000000
52
+ #define IMX335_LINK_FREQ 594000000LL
53
53
#define IMX335_NUM_DATA_LANES 4
54
54
55
55
#define IMX335_REG_MIN 0x00
@@ -134,6 +134,7 @@ struct imx335_mode {
134
134
* @vblank: Vertical blanking in lines
135
135
* @cur_mode: Pointer to current selected sensor mode
136
136
* @mutex: Mutex for serializing sensor controls
137
+ * @link_freq_bitmap: Menu bitmap for link_freq_ctrl
137
138
* @cur_mbus_code: Currently selected media bus format code
138
139
*/
139
140
struct imx335 {
@@ -157,6 +158,7 @@ struct imx335 {
157
158
u32 vblank ;
158
159
const struct imx335_mode * cur_mode ;
159
160
struct mutex mutex ;
161
+ unsigned long link_freq_bitmap ;
160
162
u32 cur_mbus_code ;
161
163
};
162
164
@@ -405,7 +407,8 @@ static int imx335_update_controls(struct imx335 *imx335,
405
407
{
406
408
int ret ;
407
409
408
- ret = __v4l2_ctrl_s_ctrl (imx335 -> link_freq_ctrl , mode -> link_freq_idx );
410
+ ret = __v4l2_ctrl_s_ctrl (imx335 -> link_freq_ctrl ,
411
+ __ffs (imx335 -> link_freq_bitmap ));
409
412
if (ret )
410
413
return ret ;
411
414
@@ -691,6 +694,13 @@ static int imx335_init_state(struct v4l2_subdev *sd,
691
694
fmt .which = sd_state ? V4L2_SUBDEV_FORMAT_TRY : V4L2_SUBDEV_FORMAT_ACTIVE ;
692
695
imx335_fill_pad_format (imx335 , & supported_mode , & fmt );
693
696
697
+ mutex_lock (& imx335 -> mutex );
698
+ __v4l2_ctrl_modify_range (imx335 -> link_freq_ctrl , 0 ,
699
+ __fls (imx335 -> link_freq_bitmap ),
700
+ ~(imx335 -> link_freq_bitmap ),
701
+ __ffs (imx335 -> link_freq_bitmap ));
702
+ mutex_unlock (& imx335 -> mutex );
703
+
694
704
return imx335_set_pad_format (sd , sd_state , & fmt );
695
705
}
696
706
@@ -939,19 +949,10 @@ static int imx335_parse_hw_config(struct imx335 *imx335)
939
949
goto done_endpoint_free ;
940
950
}
941
951
942
- if (!bus_cfg .nr_of_link_frequencies ) {
943
- dev_err (imx335 -> dev , "no link frequencies defined\n" );
944
- ret = - EINVAL ;
945
- goto done_endpoint_free ;
946
- }
947
-
948
- for (i = 0 ; i < bus_cfg .nr_of_link_frequencies ; i ++ )
949
- if (bus_cfg .link_frequencies [i ] == IMX335_LINK_FREQ )
950
- goto done_endpoint_free ;
951
-
952
- dev_err (imx335 -> dev , "no compatible link frequencies found\n" );
953
-
954
- ret = - EINVAL ;
952
+ ret = v4l2_link_freq_to_bitmap (imx335 -> dev , bus_cfg .link_frequencies ,
953
+ bus_cfg .nr_of_link_frequencies ,
954
+ link_freq , ARRAY_SIZE (link_freq ),
955
+ & imx335 -> link_freq_bitmap );
955
956
956
957
done_endpoint_free :
957
958
v4l2_fwnode_endpoint_free (& bus_cfg );
@@ -1099,9 +1100,8 @@ static int imx335_init_controls(struct imx335 *imx335)
1099
1100
imx335 -> link_freq_ctrl = v4l2_ctrl_new_int_menu (ctrl_hdlr ,
1100
1101
& imx335_ctrl_ops ,
1101
1102
V4L2_CID_LINK_FREQ ,
1102
- ARRAY_SIZE (link_freq ) -
1103
- 1 ,
1104
- mode -> link_freq_idx ,
1103
+ __fls (imx335 -> link_freq_bitmap ),
1104
+ __ffs (imx335 -> link_freq_bitmap ),
1105
1105
link_freq );
1106
1106
if (imx335 -> link_freq_ctrl )
1107
1107
imx335 -> link_freq_ctrl -> flags |= V4L2_CTRL_FLAG_READ_ONLY ;
0 commit comments