189
189
/* Initial number of frames to skip to avoid possible garbage */
190
190
#define ADV7180_NUM_OF_SKIP_FRAMES 2
191
191
192
+ enum adv7180_link_freq_idx {
193
+ INTERLACED_IDX ,
194
+ I2P_IDX ,
195
+ };
196
+
197
+ static const s64 adv7180_link_freqs [] = {
198
+ [INTERLACED_IDX ] = 108000000 ,
199
+ [I2P_IDX ] = 216000000 ,
200
+ };
201
+
192
202
static int dbg_input ;
193
203
module_param (dbg_input , int , 0644 );
194
204
MODULE_PARM_DESC (dbg_input , "Input number (0-31)" );
@@ -228,6 +238,7 @@ struct adv7180_state {
228
238
const struct adv7180_chip_info * chip_info ;
229
239
enum v4l2_field field ;
230
240
bool force_bt656_4 ;
241
+ struct v4l2_ctrl * link_freq ;
231
242
};
232
243
#define to_adv7180_sd (_ctrl ) (&container_of(_ctrl->handler, \
233
244
struct adv7180_state, \
@@ -629,6 +640,9 @@ static int adv7180_s_ctrl(struct v4l2_ctrl *ctrl)
629
640
630
641
if (ret )
631
642
return ret ;
643
+ if (ctrl -> flags & V4L2_CTRL_FLAG_READ_ONLY )
644
+ goto unlock ;
645
+
632
646
val = ctrl -> val ;
633
647
switch (ctrl -> id ) {
634
648
case V4L2_CID_BRIGHTNESS :
@@ -670,6 +684,7 @@ static int adv7180_s_ctrl(struct v4l2_ctrl *ctrl)
670
684
ret = - EINVAL ;
671
685
}
672
686
687
+ unlock :
673
688
mutex_unlock (& state -> mutex );
674
689
return ret ;
675
690
}
@@ -690,7 +705,7 @@ static const struct v4l2_ctrl_config adv7180_ctrl_fast_switch = {
690
705
691
706
static int adv7180_init_controls (struct adv7180_state * state )
692
707
{
693
- v4l2_ctrl_handler_init (& state -> ctrl_hdl , 4 );
708
+ v4l2_ctrl_handler_init (& state -> ctrl_hdl , 5 );
694
709
695
710
v4l2_ctrl_new_std (& state -> ctrl_hdl , & adv7180_ctrl_ops ,
696
711
V4L2_CID_BRIGHTNESS , ADV7180_BRI_MIN ,
@@ -712,6 +727,17 @@ static int adv7180_init_controls(struct adv7180_state *state)
712
727
0 , ARRAY_SIZE (test_pattern_menu ) - 1 ,
713
728
test_pattern_menu );
714
729
730
+ if (state -> chip_info -> flags & ADV7180_FLAG_MIPI_CSI2 ) {
731
+ state -> link_freq =
732
+ v4l2_ctrl_new_int_menu (& state -> ctrl_hdl ,
733
+ & adv7180_ctrl_ops ,
734
+ V4L2_CID_LINK_FREQ ,
735
+ ARRAY_SIZE (adv7180_link_freqs ) - 1 ,
736
+ 0 , adv7180_link_freqs );
737
+ if (state -> link_freq )
738
+ state -> link_freq -> flags |= V4L2_CTRL_FLAG_READ_ONLY ;
739
+ }
740
+
715
741
state -> sd .ctrl_handler = & state -> ctrl_hdl ;
716
742
if (state -> ctrl_hdl .error ) {
717
743
int err = state -> ctrl_hdl .error ;
@@ -844,6 +870,10 @@ static int adv7180_set_pad_format(struct v4l2_subdev *sd,
844
870
adv7180_set_power (state , false);
845
871
adv7180_set_field_mode (state );
846
872
adv7180_set_power (state , true);
873
+ if (state -> chip_info -> flags & ADV7180_FLAG_MIPI_CSI2 )
874
+ __v4l2_ctrl_s_ctrl (state -> link_freq ,
875
+ (state -> field == V4L2_FIELD_NONE ) ?
876
+ I2P_IDX : INTERLACED_IDX );
847
877
}
848
878
} else {
849
879
framefmt = v4l2_subdev_state_get_format (sd_state , 0 );
0 commit comments