imx334.c (5ca5515ab16ab12c4194101d91c4c3c3cf179528) imx334.c (7462df589954c978b01dd515bf20d05132969988)
1// SPDX-License-Identifier: GPL-2.0-only
2/*
3 * Sony imx334 sensor driver
4 *
5 * Copyright (C) 2021 Intel Corporation
6 */
7#include <asm/unaligned.h>
8

--- 65 unchanged lines hidden (view full) ---

74 u32 num_of_regs;
75 const struct imx334_reg *regs;
76};
77
78/**
79 * struct imx334_mode - imx334 sensor mode structure
80 * @width: Frame width
81 * @height: Frame height
1// SPDX-License-Identifier: GPL-2.0-only
2/*
3 * Sony imx334 sensor driver
4 *
5 * Copyright (C) 2021 Intel Corporation
6 */
7#include <asm/unaligned.h>
8

--- 65 unchanged lines hidden (view full) ---

74 u32 num_of_regs;
75 const struct imx334_reg *regs;
76};
77
78/**
79 * struct imx334_mode - imx334 sensor mode structure
80 * @width: Frame width
81 * @height: Frame height
82 * @code: Format code
83 * @hblank: Horizontal blanking in lines
84 * @vblank: Vertical blanking in lines
85 * @vblank_min: Minimal vertical blanking in lines
86 * @vblank_max: Maximum vertical blanking in lines
87 * @pclk: Sensor pixel clock
88 * @link_freq_idx: Link frequency index
89 * @reg_list: Register list for sensor mode
90 */
91struct imx334_mode {
92 u32 width;
93 u32 height;
82 * @hblank: Horizontal blanking in lines
83 * @vblank: Vertical blanking in lines
84 * @vblank_min: Minimal vertical blanking in lines
85 * @vblank_max: Maximum vertical blanking in lines
86 * @pclk: Sensor pixel clock
87 * @link_freq_idx: Link frequency index
88 * @reg_list: Register list for sensor mode
89 */
90struct imx334_mode {
91 u32 width;
92 u32 height;
94 u32 code;
95 u32 hblank;
96 u32 vblank;
97 u32 vblank_min;
98 u32 vblank_max;
99 u64 pclk;
100 u32 link_freq_idx;
101 struct imx334_reg_list reg_list;
102};

--- 11 unchanged lines hidden (view full) ---

114 * @pclk_ctrl: Pointer to pixel clock control
115 * @hblank_ctrl: Pointer to horizontal blanking control
116 * @vblank_ctrl: Pointer to vertical blanking control
117 * @exp_ctrl: Pointer to exposure control
118 * @again_ctrl: Pointer to analog gain control
119 * @vblank: Vertical blanking in lines
120 * @cur_mode: Pointer to current selected sensor mode
121 * @mutex: Mutex for serializing sensor controls
93 u32 hblank;
94 u32 vblank;
95 u32 vblank_min;
96 u32 vblank_max;
97 u64 pclk;
98 u32 link_freq_idx;
99 struct imx334_reg_list reg_list;
100};

--- 11 unchanged lines hidden (view full) ---

112 * @pclk_ctrl: Pointer to pixel clock control
113 * @hblank_ctrl: Pointer to horizontal blanking control
114 * @vblank_ctrl: Pointer to vertical blanking control
115 * @exp_ctrl: Pointer to exposure control
116 * @again_ctrl: Pointer to analog gain control
117 * @vblank: Vertical blanking in lines
118 * @cur_mode: Pointer to current selected sensor mode
119 * @mutex: Mutex for serializing sensor controls
120 * @cur_code: current selected format code
122 * @streaming: Flag indicating streaming state
123 */
124struct imx334 {
125 struct device *dev;
126 struct i2c_client *client;
127 struct v4l2_subdev sd;
128 struct media_pad pad;
129 struct gpio_desc *reset_gpio;

--- 5 unchanged lines hidden (view full) ---

135 struct v4l2_ctrl *vblank_ctrl;
136 struct {
137 struct v4l2_ctrl *exp_ctrl;
138 struct v4l2_ctrl *again_ctrl;
139 };
140 u32 vblank;
141 const struct imx334_mode *cur_mode;
142 struct mutex mutex;
121 * @streaming: Flag indicating streaming state
122 */
123struct imx334 {
124 struct device *dev;
125 struct i2c_client *client;
126 struct v4l2_subdev sd;
127 struct media_pad pad;
128 struct gpio_desc *reset_gpio;

--- 5 unchanged lines hidden (view full) ---

134 struct v4l2_ctrl *vblank_ctrl;
135 struct {
136 struct v4l2_ctrl *exp_ctrl;
137 struct v4l2_ctrl *again_ctrl;
138 };
139 u32 vblank;
140 const struct imx334_mode *cur_mode;
141 struct mutex mutex;
142 u32 cur_code;
143 bool streaming;
144};
145
146static const s64 link_freq[] = {
147 IMX334_LINK_FREQ,
148};
149
143 bool streaming;
144};
145
146static const s64 link_freq[] = {
147 IMX334_LINK_FREQ,
148};
149
150/* Sensor mode registers */
150/* Sensor mode registers for 1920x1080@30fps */
151static const struct imx334_reg mode_1920x1080_regs[] = {
152 {0x3000, 0x01},
153 {0x3018, 0x04},
154 {0x3030, 0xca},
155 {0x3031, 0x08},
156 {0x3032, 0x00},
157 {0x3034, 0x4c},
158 {0x3035, 0x04},
159 {0x302c, 0xf0},
160 {0x302d, 0x03},
161 {0x302e, 0x80},
162 {0x302f, 0x07},
163 {0x3074, 0xcc},
164 {0x3075, 0x02},
165 {0x308e, 0xcd},
166 {0x308f, 0x02},
167 {0x3076, 0x38},
168 {0x3077, 0x04},
169 {0x3090, 0x38},
170 {0x3091, 0x04},
171 {0x3308, 0x38},
172 {0x3309, 0x04},
173 {0x30C6, 0x00},
174 {0x30c7, 0x00},
175 {0x30ce, 0x00},
176 {0x30cf, 0x00},
177 {0x30d8, 0x18},
178 {0x30d9, 0x0a},
179 {0x304c, 0x00},
180 {0x304e, 0x00},
181 {0x304f, 0x00},
182 {0x3050, 0x00},
183 {0x30b6, 0x00},
184 {0x30b7, 0x00},
185 {0x3116, 0x08},
186 {0x3117, 0x00},
187 {0x31a0, 0x20},
188 {0x31a1, 0x0f},
189 {0x300c, 0x3b},
190 {0x300d, 0x29},
191 {0x314c, 0x29},
192 {0x314d, 0x01},
193 {0x315a, 0x06},
194 {0x3168, 0xa0},
195 {0x316a, 0x7e},
196 {0x319e, 0x02},
197 {0x3199, 0x00},
198 {0x319d, 0x00},
199 {0x31dd, 0x03},
200 {0x3300, 0x00},
201 {0x341c, 0xff},
202 {0x341d, 0x01},
203 {0x3a01, 0x03},
204 {0x3a18, 0x7f},
205 {0x3a19, 0x00},
206 {0x3a1a, 0x37},
207 {0x3a1b, 0x00},
208 {0x3a1c, 0x37},
209 {0x3a1d, 0x00},
210 {0x3a1e, 0xf7},
211 {0x3a1f, 0x00},
212 {0x3a20, 0x3f},
213 {0x3a21, 0x00},
214 {0x3a20, 0x6f},
215 {0x3a21, 0x00},
216 {0x3a20, 0x3f},
217 {0x3a21, 0x00},
218 {0x3a20, 0x5f},
219 {0x3a21, 0x00},
220 {0x3a20, 0x2f},
221 {0x3a21, 0x00},
222 {0x3078, 0x02},
223 {0x3079, 0x00},
224 {0x307a, 0x00},
225 {0x307b, 0x00},
226 {0x3080, 0x02},
227 {0x3081, 0x00},
228 {0x3082, 0x00},
229 {0x3083, 0x00},
230 {0x3088, 0x02},
231 {0x3094, 0x00},
232 {0x3095, 0x00},
233 {0x3096, 0x00},
234 {0x309b, 0x02},
235 {0x309c, 0x00},
236 {0x309d, 0x00},
237 {0x309e, 0x00},
238 {0x30a4, 0x00},
239 {0x30a5, 0x00},
240 {0x3288, 0x21},
241 {0x328a, 0x02},
242 {0x3414, 0x05},
243 {0x3416, 0x18},
244 {0x35Ac, 0x0e},
245 {0x3648, 0x01},
246 {0x364a, 0x04},
247 {0x364c, 0x04},
248 {0x3678, 0x01},
249 {0x367c, 0x31},
250 {0x367e, 0x31},
251 {0x3708, 0x02},
252 {0x3714, 0x01},
253 {0x3715, 0x02},
254 {0x3716, 0x02},
255 {0x3717, 0x02},
256 {0x371c, 0x3d},
257 {0x371d, 0x3f},
258 {0x372c, 0x00},
259 {0x372d, 0x00},
260 {0x372e, 0x46},
261 {0x372f, 0x00},
262 {0x3730, 0x89},
263 {0x3731, 0x00},
264 {0x3732, 0x08},
265 {0x3733, 0x01},
266 {0x3734, 0xfe},
267 {0x3735, 0x05},
268 {0x375d, 0x00},
269 {0x375e, 0x00},
270 {0x375f, 0x61},
271 {0x3760, 0x06},
272 {0x3768, 0x1b},
273 {0x3769, 0x1b},
274 {0x376a, 0x1a},
275 {0x376b, 0x19},
276 {0x376c, 0x18},
277 {0x376d, 0x14},
278 {0x376e, 0x0f},
279 {0x3776, 0x00},
280 {0x3777, 0x00},
281 {0x3778, 0x46},
282 {0x3779, 0x00},
283 {0x377a, 0x08},
284 {0x377b, 0x01},
285 {0x377c, 0x45},
286 {0x377d, 0x01},
287 {0x377e, 0x23},
288 {0x377f, 0x02},
289 {0x3780, 0xd9},
290 {0x3781, 0x03},
291 {0x3782, 0xf5},
292 {0x3783, 0x06},
293 {0x3784, 0xa5},
294 {0x3788, 0x0f},
295 {0x378a, 0xd9},
296 {0x378b, 0x03},
297 {0x378c, 0xeb},
298 {0x378d, 0x05},
299 {0x378e, 0x87},
300 {0x378f, 0x06},
301 {0x3790, 0xf5},
302 {0x3792, 0x43},
303 {0x3794, 0x7a},
304 {0x3796, 0xa1},
305 {0x37b0, 0x37},
306 {0x3e04, 0x0e},
307 {0x30e8, 0x50},
308 {0x30e9, 0x00},
309 {0x3e04, 0x0e},
310 {0x3002, 0x00},
311};
312
313/* Sensor mode registers for 3840x2160@30fps */
151static const struct imx334_reg mode_3840x2160_regs[] = {
152 {0x3000, 0x01},
153 {0x3002, 0x00},
154 {0x3018, 0x04},
155 {0x37b0, 0x36},
156 {0x304c, 0x00},
157 {0x300c, 0x3b},
158 {0x300d, 0x2a},

--- 99 unchanged lines hidden (view full) ---

258 {0x3a24, 0x6f},
259 {0x3a25, 0x00},
260 {0x3a26, 0xb7},
261 {0x3a27, 0x00},
262 {0x3a28, 0x5f},
263 {0x3a29, 0x00},
264};
265
314static const struct imx334_reg mode_3840x2160_regs[] = {
315 {0x3000, 0x01},
316 {0x3002, 0x00},
317 {0x3018, 0x04},
318 {0x37b0, 0x36},
319 {0x304c, 0x00},
320 {0x300c, 0x3b},
321 {0x300d, 0x2a},

--- 99 unchanged lines hidden (view full) ---

421 {0x3a24, 0x6f},
422 {0x3a25, 0x00},
423 {0x3a26, 0xb7},
424 {0x3a27, 0x00},
425 {0x3a28, 0x5f},
426 {0x3a29, 0x00},
427};
428
429static const struct imx334_reg raw10_framefmt_regs[] = {
430 {0x3050, 0x00},
431 {0x319d, 0x00},
432 {0x341c, 0xff},
433 {0x341d, 0x01},
434};
435
436static const struct imx334_reg raw12_framefmt_regs[] = {
437 {0x3050, 0x01},
438 {0x319d, 0x01},
439 {0x341c, 0x47},
440 {0x341d, 0x00},
441};
442
443static const u32 imx334_mbus_codes[] = {
444 MEDIA_BUS_FMT_SRGGB12_1X12,
445 MEDIA_BUS_FMT_SRGGB10_1X10,
446};
447
266/* Supported sensor mode configurations */
448/* Supported sensor mode configurations */
267static const struct imx334_mode supported_mode = {
268 .width = 3840,
269 .height = 2160,
270 .hblank = 560,
271 .vblank = 2340,
272 .vblank_min = 90,
273 .vblank_max = 132840,
274 .pclk = 594000000,
275 .link_freq_idx = 0,
276 .code = MEDIA_BUS_FMT_SRGGB12_1X12,
277 .reg_list = {
278 .num_of_regs = ARRAY_SIZE(mode_3840x2160_regs),
279 .regs = mode_3840x2160_regs,
449static const struct imx334_mode supported_modes[] = {
450 {
451 .width = 3840,
452 .height = 2160,
453 .hblank = 560,
454 .vblank = 2340,
455 .vblank_min = 90,
456 .vblank_max = 132840,
457 .pclk = 594000000,
458 .link_freq_idx = 0,
459 .reg_list = {
460 .num_of_regs = ARRAY_SIZE(mode_3840x2160_regs),
461 .regs = mode_3840x2160_regs,
462 },
463 }, {
464 .width = 1920,
465 .height = 1080,
466 .hblank = 2480,
467 .vblank = 1170,
468 .vblank_min = 45,
469 .vblank_max = 132840,
470 .pclk = 297000000,
471 .link_freq_idx = 0,
472 .reg_list = {
473 .num_of_regs = ARRAY_SIZE(mode_1920x1080_regs),
474 .regs = mode_1920x1080_regs,
475 },
280 },
281};
282
283/**
284 * to_imx334() - imv334 V4L2 sub-device to imx334 device.
285 * @subdev: pointer to imx334 V4L2 sub-device
286 *
287 * Return: pointer to imx334 device

--- 225 unchanged lines hidden (view full) ---

513 return ret;
514}
515
516/* V4l2 subdevice control ops*/
517static const struct v4l2_ctrl_ops imx334_ctrl_ops = {
518 .s_ctrl = imx334_set_ctrl,
519};
520
476 },
477};
478
479/**
480 * to_imx334() - imv334 V4L2 sub-device to imx334 device.
481 * @subdev: pointer to imx334 V4L2 sub-device
482 *
483 * Return: pointer to imx334 device

--- 225 unchanged lines hidden (view full) ---

709 return ret;
710}
711
712/* V4l2 subdevice control ops*/
713static const struct v4l2_ctrl_ops imx334_ctrl_ops = {
714 .s_ctrl = imx334_set_ctrl,
715};
716
717static int imx334_get_format_code(struct imx334 *imx334, u32 code)
718{
719 unsigned int i;
720
721 for (i = 0; i < ARRAY_SIZE(imx334_mbus_codes); i++) {
722 if (imx334_mbus_codes[i] == code)
723 return imx334_mbus_codes[i];
724 }
725
726 return imx334_mbus_codes[0];
727}
728
521/**
522 * imx334_enum_mbus_code() - Enumerate V4L2 sub-device mbus codes
523 * @sd: pointer to imx334 V4L2 sub-device structure
524 * @sd_state: V4L2 sub-device state
525 * @code: V4L2 sub-device code enumeration need to be filled
526 *
527 * Return: 0 if successful, error code otherwise.
528 */
529static int imx334_enum_mbus_code(struct v4l2_subdev *sd,
530 struct v4l2_subdev_state *sd_state,
531 struct v4l2_subdev_mbus_code_enum *code)
532{
729/**
730 * imx334_enum_mbus_code() - Enumerate V4L2 sub-device mbus codes
731 * @sd: pointer to imx334 V4L2 sub-device structure
732 * @sd_state: V4L2 sub-device state
733 * @code: V4L2 sub-device code enumeration need to be filled
734 *
735 * Return: 0 if successful, error code otherwise.
736 */
737static int imx334_enum_mbus_code(struct v4l2_subdev *sd,
738 struct v4l2_subdev_state *sd_state,
739 struct v4l2_subdev_mbus_code_enum *code)
740{
533 if (code->index > 0)
741 if (code->index >= ARRAY_SIZE(imx334_mbus_codes))
534 return -EINVAL;
535
742 return -EINVAL;
743
536 code->code = supported_mode.code;
744 code->code = imx334_mbus_codes[code->index];
537
538 return 0;
539}
540
541/**
542 * imx334_enum_frame_size() - Enumerate V4L2 sub-device frame sizes
543 * @sd: pointer to imx334 V4L2 sub-device structure
544 * @sd_state: V4L2 sub-device state
545 * @fsize: V4L2 sub-device size enumeration need to be filled
546 *
547 * Return: 0 if successful, error code otherwise.
548 */
549static int imx334_enum_frame_size(struct v4l2_subdev *sd,
550 struct v4l2_subdev_state *sd_state,
551 struct v4l2_subdev_frame_size_enum *fsize)
552{
745
746 return 0;
747}
748
749/**
750 * imx334_enum_frame_size() - Enumerate V4L2 sub-device frame sizes
751 * @sd: pointer to imx334 V4L2 sub-device structure
752 * @sd_state: V4L2 sub-device state
753 * @fsize: V4L2 sub-device size enumeration need to be filled
754 *
755 * Return: 0 if successful, error code otherwise.
756 */
757static int imx334_enum_frame_size(struct v4l2_subdev *sd,
758 struct v4l2_subdev_state *sd_state,
759 struct v4l2_subdev_frame_size_enum *fsize)
760{
553 if (fsize->index > 0)
761 struct imx334 *imx334 = to_imx334(sd);
762 u32 code;
763
764 if (fsize->index >= ARRAY_SIZE(supported_modes))
554 return -EINVAL;
555
765 return -EINVAL;
766
556 if (fsize->code != supported_mode.code)
767 code = imx334_get_format_code(imx334, fsize->code);
768
769 if (fsize->code != code)
557 return -EINVAL;
558
770 return -EINVAL;
771
559 fsize->min_width = supported_mode.width;
772 fsize->min_width = supported_modes[fsize->index].width;
560 fsize->max_width = fsize->min_width;
773 fsize->max_width = fsize->min_width;
561 fsize->min_height = supported_mode.height;
774 fsize->min_height = supported_modes[fsize->index].height;
562 fsize->max_height = fsize->min_height;
563
564 return 0;
565}
566
567/**
568 * imx334_fill_pad_format() - Fill subdevice pad format
569 * from selected sensor mode
570 * @imx334: pointer to imx334 device
571 * @mode: pointer to imx334_mode sensor mode
572 * @fmt: V4L2 sub-device format need to be filled
573 */
574static void imx334_fill_pad_format(struct imx334 *imx334,
575 const struct imx334_mode *mode,
576 struct v4l2_subdev_format *fmt)
577{
578 fmt->format.width = mode->width;
579 fmt->format.height = mode->height;
775 fsize->max_height = fsize->min_height;
776
777 return 0;
778}
779
780/**
781 * imx334_fill_pad_format() - Fill subdevice pad format
782 * from selected sensor mode
783 * @imx334: pointer to imx334 device
784 * @mode: pointer to imx334_mode sensor mode
785 * @fmt: V4L2 sub-device format need to be filled
786 */
787static void imx334_fill_pad_format(struct imx334 *imx334,
788 const struct imx334_mode *mode,
789 struct v4l2_subdev_format *fmt)
790{
791 fmt->format.width = mode->width;
792 fmt->format.height = mode->height;
580 fmt->format.code = mode->code;
581 fmt->format.field = V4L2_FIELD_NONE;
582 fmt->format.colorspace = V4L2_COLORSPACE_RAW;
583 fmt->format.ycbcr_enc = V4L2_YCBCR_ENC_DEFAULT;
584 fmt->format.quantization = V4L2_QUANTIZATION_DEFAULT;
585 fmt->format.xfer_func = V4L2_XFER_FUNC_NONE;
586}
587
588/**

--- 13 unchanged lines hidden (view full) ---

602 mutex_lock(&imx334->mutex);
603
604 if (fmt->which == V4L2_SUBDEV_FORMAT_TRY) {
605 struct v4l2_mbus_framefmt *framefmt;
606
607 framefmt = v4l2_subdev_get_try_format(sd, sd_state, fmt->pad);
608 fmt->format = *framefmt;
609 } else {
793 fmt->format.field = V4L2_FIELD_NONE;
794 fmt->format.colorspace = V4L2_COLORSPACE_RAW;
795 fmt->format.ycbcr_enc = V4L2_YCBCR_ENC_DEFAULT;
796 fmt->format.quantization = V4L2_QUANTIZATION_DEFAULT;
797 fmt->format.xfer_func = V4L2_XFER_FUNC_NONE;
798}
799
800/**

--- 13 unchanged lines hidden (view full) ---

814 mutex_lock(&imx334->mutex);
815
816 if (fmt->which == V4L2_SUBDEV_FORMAT_TRY) {
817 struct v4l2_mbus_framefmt *framefmt;
818
819 framefmt = v4l2_subdev_get_try_format(sd, sd_state, fmt->pad);
820 fmt->format = *framefmt;
821 } else {
822 fmt->format.code = imx334->cur_code;
610 imx334_fill_pad_format(imx334, imx334->cur_mode, fmt);
611 }
612
613 mutex_unlock(&imx334->mutex);
614
615 return 0;
616}
617

--- 10 unchanged lines hidden (view full) ---

628 struct v4l2_subdev_format *fmt)
629{
630 struct imx334 *imx334 = to_imx334(sd);
631 const struct imx334_mode *mode;
632 int ret = 0;
633
634 mutex_lock(&imx334->mutex);
635
823 imx334_fill_pad_format(imx334, imx334->cur_mode, fmt);
824 }
825
826 mutex_unlock(&imx334->mutex);
827
828 return 0;
829}
830

--- 10 unchanged lines hidden (view full) ---

841 struct v4l2_subdev_format *fmt)
842{
843 struct imx334 *imx334 = to_imx334(sd);
844 const struct imx334_mode *mode;
845 int ret = 0;
846
847 mutex_lock(&imx334->mutex);
848
636 mode = &supported_mode;
849 mode = v4l2_find_nearest_size(supported_modes,
850 ARRAY_SIZE(supported_modes),
851 width, height,
852 fmt->format.width, fmt->format.height);
853
637 imx334_fill_pad_format(imx334, mode, fmt);
854 imx334_fill_pad_format(imx334, mode, fmt);
855 fmt->format.code = imx334_get_format_code(imx334, fmt->format.code);
638
639 if (fmt->which == V4L2_SUBDEV_FORMAT_TRY) {
640 struct v4l2_mbus_framefmt *framefmt;
641
642 framefmt = v4l2_subdev_get_try_format(sd, sd_state, fmt->pad);
643 *framefmt = fmt->format;
856
857 if (fmt->which == V4L2_SUBDEV_FORMAT_TRY) {
858 struct v4l2_mbus_framefmt *framefmt;
859
860 framefmt = v4l2_subdev_get_try_format(sd, sd_state, fmt->pad);
861 *framefmt = fmt->format;
644 } else {
862 } else if (imx334->cur_mode != mode || imx334->cur_code != fmt->format.code) {
863 imx334->cur_code = fmt->format.code;
645 ret = imx334_update_controls(imx334, mode);
646 if (!ret)
647 imx334->cur_mode = mode;
648 }
649
650 mutex_unlock(&imx334->mutex);
651
652 return ret;

--- 8 unchanged lines hidden (view full) ---

661 */
662static int imx334_init_pad_cfg(struct v4l2_subdev *sd,
663 struct v4l2_subdev_state *sd_state)
664{
665 struct imx334 *imx334 = to_imx334(sd);
666 struct v4l2_subdev_format fmt = { 0 };
667
668 fmt.which = sd_state ? V4L2_SUBDEV_FORMAT_TRY : V4L2_SUBDEV_FORMAT_ACTIVE;
864 ret = imx334_update_controls(imx334, mode);
865 if (!ret)
866 imx334->cur_mode = mode;
867 }
868
869 mutex_unlock(&imx334->mutex);
870
871 return ret;

--- 8 unchanged lines hidden (view full) ---

880 */
881static int imx334_init_pad_cfg(struct v4l2_subdev *sd,
882 struct v4l2_subdev_state *sd_state)
883{
884 struct imx334 *imx334 = to_imx334(sd);
885 struct v4l2_subdev_format fmt = { 0 };
886
887 fmt.which = sd_state ? V4L2_SUBDEV_FORMAT_TRY : V4L2_SUBDEV_FORMAT_ACTIVE;
669 imx334_fill_pad_format(imx334, &supported_mode, &fmt);
888 imx334_fill_pad_format(imx334, &supported_modes[0], &fmt);
670
671 return imx334_set_pad_format(sd, sd_state, &fmt);
672}
673
889
890 return imx334_set_pad_format(sd, sd_state, &fmt);
891}
892
893static int imx334_set_framefmt(struct imx334 *imx334)
894{
895 switch (imx334->cur_code) {
896 case MEDIA_BUS_FMT_SRGGB10_1X10:
897 return imx334_write_regs(imx334, raw10_framefmt_regs,
898 ARRAY_SIZE(raw10_framefmt_regs));
899
900 case MEDIA_BUS_FMT_SRGGB12_1X12:
901 return imx334_write_regs(imx334, raw12_framefmt_regs,
902 ARRAY_SIZE(raw12_framefmt_regs));
903 }
904
905 return -EINVAL;
906}
907
674/**
675 * imx334_start_streaming() - Start sensor stream
676 * @imx334: pointer to imx334 device
677 *
678 * Return: 0 if successful, error code otherwise.
679 */
680static int imx334_start_streaming(struct imx334 *imx334)
681{

--- 4 unchanged lines hidden (view full) ---

686 reg_list = &imx334->cur_mode->reg_list;
687 ret = imx334_write_regs(imx334, reg_list->regs,
688 reg_list->num_of_regs);
689 if (ret) {
690 dev_err(imx334->dev, "fail to write initial registers");
691 return ret;
692 }
693
908/**
909 * imx334_start_streaming() - Start sensor stream
910 * @imx334: pointer to imx334 device
911 *
912 * Return: 0 if successful, error code otherwise.
913 */
914static int imx334_start_streaming(struct imx334 *imx334)
915{

--- 4 unchanged lines hidden (view full) ---

920 reg_list = &imx334->cur_mode->reg_list;
921 ret = imx334_write_regs(imx334, reg_list->regs,
922 reg_list->num_of_regs);
923 if (ret) {
924 dev_err(imx334->dev, "fail to write initial registers");
925 return ret;
926 }
927
928 ret = imx334_set_framefmt(imx334);
929 if (ret) {
930 dev_err(imx334->dev, "%s failed to set frame format: %d\n",
931 __func__, ret);
932 return ret;
933 }
934
694 /* Setup handler will write actual exposure and gain */
695 ret = __v4l2_ctrl_handler_setup(imx334->sd.ctrl_handler);
696 if (ret) {
697 dev_err(imx334->dev, "fail to setup handler");
698 return ret;
699 }
700
701 /* Start streaming */

--- 354 unchanged lines hidden (view full) ---

1056 /* Check module identity */
1057 ret = imx334_detect(imx334);
1058 if (ret) {
1059 dev_err(imx334->dev, "failed to find sensor: %d", ret);
1060 goto error_power_off;
1061 }
1062
1063 /* Set default mode to max resolution */
935 /* Setup handler will write actual exposure and gain */
936 ret = __v4l2_ctrl_handler_setup(imx334->sd.ctrl_handler);
937 if (ret) {
938 dev_err(imx334->dev, "fail to setup handler");
939 return ret;
940 }
941
942 /* Start streaming */

--- 354 unchanged lines hidden (view full) ---

1297 /* Check module identity */
1298 ret = imx334_detect(imx334);
1299 if (ret) {
1300 dev_err(imx334->dev, "failed to find sensor: %d", ret);
1301 goto error_power_off;
1302 }
1303
1304 /* Set default mode to max resolution */
1064 imx334->cur_mode = &supported_mode;
1305 imx334->cur_mode = &supported_modes[0];
1306 imx334->cur_code = imx334_mbus_codes[0];
1065 imx334->vblank = imx334->cur_mode->vblank;
1066
1067 ret = imx334_init_controls(imx334);
1068 if (ret) {
1069 dev_err(imx334->dev, "failed to init controls: %d", ret);
1070 goto error_power_off;
1071 }
1072

--- 83 unchanged lines hidden ---
1307 imx334->vblank = imx334->cur_mode->vblank;
1308
1309 ret = imx334_init_controls(imx334);
1310 if (ret) {
1311 dev_err(imx334->dev, "failed to init controls: %d", ret);
1312 goto error_power_off;
1313 }
1314

--- 83 unchanged lines hidden ---