9696
9797#define VSRSTS_RETRIES 20
9898
99- #define RZG2L_CSI2_MIN_WIDTH 320
100- #define RZG2L_CSI2_MIN_HEIGHT 240
101- #define RZG2L_CSI2_MAX_WIDTH 2800
102- #define RZG2L_CSI2_MAX_HEIGHT 4095
103-
104- #define RZG2L_CSI2_DEFAULT_WIDTH RZG2L_CSI2_MIN_WIDTH
105- #define RZG2L_CSI2_DEFAULT_HEIGHT RZG2L_CSI2_MIN_HEIGHT
10699#define RZG2L_CSI2_DEFAULT_FMT MEDIA_BUS_FMT_UYVY8_1X16
107100
108101enum rzg2l_csi2_pads {
@@ -137,6 +130,10 @@ struct rzg2l_csi2_info {
137130 int (* dphy_enable )(struct rzg2l_csi2 * csi2 );
138131 int (* dphy_disable )(struct rzg2l_csi2 * csi2 );
139132 bool has_system_clk ;
133+ unsigned int min_width ;
134+ unsigned int min_height ;
135+ unsigned int max_width ;
136+ unsigned int max_height ;
140137};
141138
142139struct rzg2l_csi2_timings {
@@ -418,6 +415,10 @@ static const struct rzg2l_csi2_info rzg2l_csi2_info = {
418415 .dphy_enable = rzg2l_csi2_dphy_enable ,
419416 .dphy_disable = rzg2l_csi2_dphy_disable ,
420417 .has_system_clk = true,
418+ .min_width = 320 ,
419+ .min_height = 240 ,
420+ .max_width = 2800 ,
421+ .max_height = 4095 ,
421422};
422423
423424static int rzg2l_csi2_dphy_setting (struct v4l2_subdev * sd , bool on )
@@ -542,6 +543,10 @@ static const struct rzg2l_csi2_info rzv2h_csi2_info = {
542543 .dphy_enable = rzv2h_csi2_dphy_enable ,
543544 .dphy_disable = rzv2h_csi2_dphy_disable ,
544545 .has_system_clk = false,
546+ .min_width = 320 ,
547+ .min_height = 240 ,
548+ .max_width = 4096 ,
549+ .max_height = 4096 ,
545550};
546551
547552static int rzg2l_csi2_mipi_link_setting (struct v4l2_subdev * sd , bool on )
@@ -631,6 +636,7 @@ static int rzg2l_csi2_set_format(struct v4l2_subdev *sd,
631636 struct v4l2_subdev_state * state ,
632637 struct v4l2_subdev_format * fmt )
633638{
639+ struct rzg2l_csi2 * csi2 = sd_to_csi2 (sd );
634640 struct v4l2_mbus_framefmt * src_format ;
635641 struct v4l2_mbus_framefmt * sink_format ;
636642
@@ -653,9 +659,11 @@ static int rzg2l_csi2_set_format(struct v4l2_subdev *sd,
653659 sink_format -> ycbcr_enc = fmt -> format .ycbcr_enc ;
654660 sink_format -> quantization = fmt -> format .quantization ;
655661 sink_format -> width = clamp_t (u32 , fmt -> format .width ,
656- RZG2L_CSI2_MIN_WIDTH , RZG2L_CSI2_MAX_WIDTH );
662+ csi2 -> info -> min_width ,
663+ csi2 -> info -> max_width );
657664 sink_format -> height = clamp_t (u32 , fmt -> format .height ,
658- RZG2L_CSI2_MIN_HEIGHT , RZG2L_CSI2_MAX_HEIGHT );
665+ csi2 -> info -> min_height ,
666+ csi2 -> info -> max_height );
659667 fmt -> format = * sink_format ;
660668
661669 /* propagate format to source pad */
@@ -668,9 +676,10 @@ static int rzg2l_csi2_init_state(struct v4l2_subdev *sd,
668676 struct v4l2_subdev_state * sd_state )
669677{
670678 struct v4l2_subdev_format fmt = { .pad = RZG2L_CSI2_SINK , };
679+ struct rzg2l_csi2 * csi2 = sd_to_csi2 (sd );
671680
672- fmt .format .width = RZG2L_CSI2_DEFAULT_WIDTH ;
673- fmt .format .height = RZG2L_CSI2_DEFAULT_HEIGHT ;
681+ fmt .format .width = csi2 -> info -> min_width ;
682+ fmt .format .height = csi2 -> info -> min_height ;
674683 fmt .format .field = V4L2_FIELD_NONE ;
675684 fmt .format .code = RZG2L_CSI2_DEFAULT_FMT ;
676685 fmt .format .colorspace = V4L2_COLORSPACE_SRGB ;
@@ -697,16 +706,18 @@ static int rzg2l_csi2_enum_frame_size(struct v4l2_subdev *sd,
697706 struct v4l2_subdev_state * sd_state ,
698707 struct v4l2_subdev_frame_size_enum * fse )
699708{
709+ struct rzg2l_csi2 * csi2 = sd_to_csi2 (sd );
710+
700711 if (fse -> index != 0 )
701712 return - EINVAL ;
702713
703714 if (!rzg2l_csi2_code_to_fmt (fse -> code ))
704715 return - EINVAL ;
705716
706- fse -> min_width = RZG2L_CSI2_MIN_WIDTH ;
707- fse -> min_height = RZG2L_CSI2_MIN_HEIGHT ;
708- fse -> max_width = RZG2L_CSI2_MAX_WIDTH ;
709- fse -> max_height = RZG2L_CSI2_MAX_HEIGHT ;
717+ fse -> min_width = csi2 -> info -> min_width ;
718+ fse -> min_height = csi2 -> info -> min_height ;
719+ fse -> max_width = csi2 -> info -> max_width ;
720+ fse -> max_height = csi2 -> info -> max_height ;
710721
711722 return 0 ;
712723}
0 commit comments