1 // SPDX-License-Identifier: GPL-2.0
3 * Driver for the OV7251 camera sensor.
5 * Copyright (c) 2017-2018, The Linux Foundation. All rights reserved.
6 * Copyright (c) 2017-2018, Linaro Ltd.
9 #include <linux/bitops.h>
10 #include <linux/clk.h>
11 #include <linux/delay.h>
12 #include <linux/device.h>
13 #include <linux/gpio/consumer.h>
14 #include <linux/i2c.h>
15 #include <linux/init.h>
16 #include <linux/module.h>
17 #include <linux/mod_devicetable.h>
18 #include <linux/pm_runtime.h>
19 #include <linux/regulator/consumer.h>
20 #include <linux/slab.h>
21 #include <linux/types.h>
22 #include <media/v4l2-ctrls.h>
23 #include <media/v4l2-fwnode.h>
24 #include <media/v4l2-subdev.h>
26 #define OV7251_SC_MODE_SELECT 0x0100
27 #define OV7251_SC_MODE_SELECT_SW_STANDBY 0x0
28 #define OV7251_SC_MODE_SELECT_STREAMING 0x1
30 #define OV7251_CHIP_ID_HIGH 0x300a
31 #define OV7251_CHIP_ID_HIGH_BYTE 0x77
32 #define OV7251_CHIP_ID_LOW 0x300b
33 #define OV7251_CHIP_ID_LOW_BYTE 0x50
34 #define OV7251_SC_GP_IO_IN1 0x3029
35 #define OV7251_AEC_EXPO_0 0x3500
36 #define OV7251_AEC_EXPO_1 0x3501
37 #define OV7251_AEC_EXPO_2 0x3502
38 #define OV7251_AEC_AGC_ADJ_0 0x350a
39 #define OV7251_AEC_AGC_ADJ_1 0x350b
40 #define OV7251_TIMING_FORMAT1 0x3820
41 #define OV7251_TIMING_FORMAT1_VFLIP BIT(2)
42 #define OV7251_TIMING_FORMAT2 0x3821
43 #define OV7251_TIMING_FORMAT2_MIRROR BIT(2)
44 #define OV7251_PRE_ISP_00 0x5e00
45 #define OV7251_PRE_ISP_00_TEST_PATTERN BIT(7)
46 #define OV7251_PLL1_PRE_DIV_REG 0x30b4
47 #define OV7251_PLL1_MULT_REG 0x30b3
48 #define OV7251_PLL1_DIVIDER_REG 0x30b1
49 #define OV7251_PLL1_PIX_DIV_REG 0x30b0
50 #define OV7251_PLL1_MIPI_DIV_REG 0x30b5
51 #define OV7251_PLL2_PRE_DIV_REG 0x3098
52 #define OV7251_PLL2_MULT_REG 0x3099
53 #define OV7251_PLL2_DIVIDER_REG 0x309d
54 #define OV7251_PLL2_SYS_DIV_REG 0x309a
55 #define OV7251_PLL2_ADC_DIV_REG 0x309b
57 #define OV7251_NATIVE_WIDTH 656
58 #define OV7251_NATIVE_HEIGHT 496
59 #define OV7251_ACTIVE_START_LEFT 4
60 #define OV7251_ACTIVE_START_TOP 4
61 #define OV7251_ACTIVE_WIDTH 648
62 #define OV7251_ACTIVE_HEIGHT 488
64 #define OV7251_FIXED_PPL 928
65 #define OV7251_TIMING_VTS_REG 0x380e
66 #define OV7251_TIMING_MIN_VTS 1
67 #define OV7251_TIMING_MAX_VTS 0xffff
68 #define OV7251_INTEGRATION_MARGIN 20
75 struct ov7251_mode_info
{
79 const struct reg_value
*data
;
85 struct v4l2_fract timeperframe
;
88 struct ov7251_pll1_cfg
{
93 unsigned int mipi_div
;
96 struct ov7251_pll2_cfg
{
100 unsigned int sys_div
;
101 unsigned int adc_div
;
105 * Rubbish ordering, but only PLL1 needs to have a separate configuration per
106 * link frequency and the array member needs to be last.
108 struct ov7251_pll_cfgs
{
109 const struct ov7251_pll2_cfg
*pll2
;
110 const struct ov7251_pll1_cfg
*pll1
[];
116 OV7251_NUM_SUPPORTED_RATES
119 enum supported_link_freqs
{
120 OV7251_LINK_FREQ_240_MHZ
,
121 OV7251_LINK_FREQ_319_2_MHZ
,
122 OV7251_NUM_SUPPORTED_LINK_FREQS
126 struct i2c_client
*i2c_client
;
128 struct v4l2_subdev sd
;
129 struct media_pad pad
;
130 struct v4l2_fwnode_endpoint ep
;
131 struct v4l2_mbus_framefmt fmt
;
132 struct v4l2_rect crop
;
136 struct regulator
*io_regulator
;
137 struct regulator
*core_regulator
;
138 struct regulator
*analog_regulator
;
140 const struct ov7251_pll_cfgs
*pll_cfgs
;
141 enum supported_link_freqs link_freq_idx
;
142 const struct ov7251_mode_info
*current_mode
;
144 struct v4l2_ctrl_handler ctrls
;
145 struct v4l2_ctrl
*pixel_clock
;
146 struct v4l2_ctrl
*link_freq
;
147 struct v4l2_ctrl
*exposure
;
148 struct v4l2_ctrl
*gain
;
149 struct v4l2_ctrl
*hblank
;
150 struct v4l2_ctrl
*vblank
;
152 /* Cached register values */
158 struct mutex lock
; /* lock to protect power state, ctrls and mode */
161 struct gpio_desc
*enable_gpio
;
164 static inline struct ov7251
*to_ov7251(struct v4l2_subdev
*sd
)
166 return container_of(sd
, struct ov7251
, sd
);
169 static const struct ov7251_pll1_cfg ov7251_pll1_cfg_19_2_mhz_240_mhz
= {
177 static const struct ov7251_pll1_cfg ov7251_pll1_cfg_19_2_mhz_319_2_mhz
= {
185 static const struct ov7251_pll1_cfg ov7251_pll1_cfg_24_mhz_240_mhz
= {
193 static const struct ov7251_pll1_cfg ov7251_pll1_cfg_24_mhz_319_2_mhz
= {
201 static const struct ov7251_pll2_cfg ov7251_pll2_cfg_19_2_mhz
= {
209 static const struct ov7251_pll2_cfg ov7251_pll2_cfg_24_mhz
= {
217 static const struct ov7251_pll_cfgs ov7251_pll_cfgs_19_2_mhz
= {
218 .pll2
= &ov7251_pll2_cfg_19_2_mhz
,
220 [OV7251_LINK_FREQ_240_MHZ
] = &ov7251_pll1_cfg_19_2_mhz_240_mhz
,
221 [OV7251_LINK_FREQ_319_2_MHZ
] = &ov7251_pll1_cfg_19_2_mhz_319_2_mhz
,
225 static const struct ov7251_pll_cfgs ov7251_pll_cfgs_24_mhz
= {
226 .pll2
= &ov7251_pll2_cfg_24_mhz
,
228 [OV7251_LINK_FREQ_240_MHZ
] = &ov7251_pll1_cfg_24_mhz_240_mhz
,
229 [OV7251_LINK_FREQ_319_2_MHZ
] = &ov7251_pll1_cfg_24_mhz_319_2_mhz
,
233 static const struct ov7251_pll_cfgs
*ov7251_pll_cfgs
[] = {
234 [OV7251_19_2_MHZ
] = &ov7251_pll_cfgs_19_2_mhz
,
235 [OV7251_24_MHZ
] = &ov7251_pll_cfgs_24_mhz
,
238 static const struct reg_value ov7251_global_init_setting
[] = {
243 static const struct reg_value ov7251_setting_vga_30fps
[] = {
295 { 0x3808, 0x02 }, /* width high */
296 { 0x3809, 0x80 }, /* width low */
297 { 0x380a, 0x01 }, /* height high */
298 { 0x380b, 0xe0 }, /* height low */
299 { 0x380c, 0x03 }, /* total horiz timing high */
300 { 0x380d, 0xa0 }, /* total horiz timing low */
301 { 0x380e, 0x06 }, /* total vertical timing high */
302 { 0x380f, 0xbc }, /* total vertical timing low */
371 static const struct reg_value ov7251_setting_vga_60fps
[] = {
423 { 0x3808, 0x02 }, /* width high */
424 { 0x3809, 0x80 }, /* width low */
425 { 0x380a, 0x01 }, /* height high */
426 { 0x380b, 0xe0 }, /* height low */
427 { 0x380c, 0x03 }, /* total horiz timing high */
428 { 0x380d, 0xa0 }, /* total horiz timing low */
429 { 0x380e, 0x03 }, /* total vertical timing high */
430 { 0x380f, 0x5c }, /* total vertical timing low */
499 static const struct reg_value ov7251_setting_vga_90fps
[] = {
551 { 0x3808, 0x02 }, /* width high */
552 { 0x3809, 0x80 }, /* width low */
553 { 0x380a, 0x01 }, /* height high */
554 { 0x380b, 0xe0 }, /* height low */
555 { 0x380c, 0x03 }, /* total horiz timing high */
556 { 0x380d, 0xa0 }, /* total horiz timing low */
557 { 0x380e, 0x02 }, /* total vertical timing high */
558 { 0x380f, 0x3c }, /* total vertical timing low */
627 static const unsigned long supported_xclk_rates
[] = {
628 [OV7251_19_2_MHZ
] = 19200000,
629 [OV7251_24_MHZ
] = 24000000,
632 static const s64 link_freq
[] = {
633 [OV7251_LINK_FREQ_240_MHZ
] = 240000000,
634 [OV7251_LINK_FREQ_319_2_MHZ
] = 319200000,
637 static const s64 pixel_rates
[] = {
638 [OV7251_LINK_FREQ_240_MHZ
] = 48000000,
639 [OV7251_LINK_FREQ_319_2_MHZ
] = 63840000,
642 static const struct ov7251_mode_info ov7251_mode_info_data
[] = {
647 .data
= ov7251_setting_vga_30fps
,
648 .data_size
= ARRAY_SIZE(ov7251_setting_vga_30fps
),
649 .exposure_max
= 1704,
660 .data
= ov7251_setting_vga_60fps
,
661 .data_size
= ARRAY_SIZE(ov7251_setting_vga_60fps
),
673 .data
= ov7251_setting_vga_90fps
,
674 .data_size
= ARRAY_SIZE(ov7251_setting_vga_90fps
),
684 static int ov7251_regulators_enable(struct ov7251
*ov7251
)
688 /* OV7251 power up sequence requires core regulator
689 * to be enabled not earlier than io regulator
692 ret
= regulator_enable(ov7251
->io_regulator
);
694 dev_err(ov7251
->dev
, "set io voltage failed\n");
698 ret
= regulator_enable(ov7251
->analog_regulator
);
700 dev_err(ov7251
->dev
, "set analog voltage failed\n");
704 ret
= regulator_enable(ov7251
->core_regulator
);
706 dev_err(ov7251
->dev
, "set core voltage failed\n");
707 goto err_disable_analog
;
713 regulator_disable(ov7251
->analog_regulator
);
716 regulator_disable(ov7251
->io_regulator
);
721 static void ov7251_regulators_disable(struct ov7251
*ov7251
)
725 ret
= regulator_disable(ov7251
->core_regulator
);
727 dev_err(ov7251
->dev
, "core regulator disable failed\n");
729 ret
= regulator_disable(ov7251
->analog_regulator
);
731 dev_err(ov7251
->dev
, "analog regulator disable failed\n");
733 ret
= regulator_disable(ov7251
->io_regulator
);
735 dev_err(ov7251
->dev
, "io regulator disable failed\n");
738 static int ov7251_write_reg(struct ov7251
*ov7251
, u16 reg
, u8 val
)
743 regbuf
[0] = reg
>> 8;
744 regbuf
[1] = reg
& 0xff;
747 ret
= i2c_master_send(ov7251
->i2c_client
, regbuf
, 3);
749 dev_err(ov7251
->dev
, "%s: write reg error %d: reg=%x, val=%x\n",
750 __func__
, ret
, reg
, val
);
757 static int ov7251_write_seq_regs(struct ov7251
*ov7251
, u16 reg
, u8
*val
,
761 u8 nregbuf
= sizeof(reg
) + num
* sizeof(*val
);
764 if (nregbuf
> sizeof(regbuf
))
767 regbuf
[0] = reg
>> 8;
768 regbuf
[1] = reg
& 0xff;
770 memcpy(regbuf
+ 2, val
, num
);
772 ret
= i2c_master_send(ov7251
->i2c_client
, regbuf
, nregbuf
);
775 "%s: write seq regs error %d: first reg=%x\n",
783 static int ov7251_read_reg(struct ov7251
*ov7251
, u16 reg
, u8
*val
)
788 regbuf
[0] = reg
>> 8;
789 regbuf
[1] = reg
& 0xff;
791 ret
= i2c_master_send(ov7251
->i2c_client
, regbuf
, 2);
793 dev_err(ov7251
->dev
, "%s: write reg error %d: reg=%x\n",
798 ret
= i2c_master_recv(ov7251
->i2c_client
, val
, 1);
800 dev_err(ov7251
->dev
, "%s: read reg error %d: reg=%x\n",
808 static int ov7251_pll_configure(struct ov7251
*ov7251
)
810 const struct ov7251_pll_cfgs
*configs
;
813 configs
= ov7251
->pll_cfgs
;
815 ret
= ov7251_write_reg(ov7251
, OV7251_PLL1_PRE_DIV_REG
,
816 configs
->pll1
[ov7251
->link_freq_idx
]->pre_div
);
820 ret
= ov7251_write_reg(ov7251
, OV7251_PLL1_MULT_REG
,
821 configs
->pll1
[ov7251
->link_freq_idx
]->mult
);
824 ret
= ov7251_write_reg(ov7251
, OV7251_PLL1_DIVIDER_REG
,
825 configs
->pll1
[ov7251
->link_freq_idx
]->div
);
829 ret
= ov7251_write_reg(ov7251
, OV7251_PLL1_PIX_DIV_REG
,
830 configs
->pll1
[ov7251
->link_freq_idx
]->pix_div
);
834 ret
= ov7251_write_reg(ov7251
, OV7251_PLL1_MIPI_DIV_REG
,
835 configs
->pll1
[ov7251
->link_freq_idx
]->mipi_div
);
839 ret
= ov7251_write_reg(ov7251
, OV7251_PLL2_PRE_DIV_REG
,
840 configs
->pll2
->pre_div
);
844 ret
= ov7251_write_reg(ov7251
, OV7251_PLL2_MULT_REG
,
845 configs
->pll2
->mult
);
849 ret
= ov7251_write_reg(ov7251
, OV7251_PLL2_DIVIDER_REG
,
854 ret
= ov7251_write_reg(ov7251
, OV7251_PLL2_SYS_DIV_REG
,
855 configs
->pll2
->sys_div
);
859 ret
= ov7251_write_reg(ov7251
, OV7251_PLL2_ADC_DIV_REG
,
860 configs
->pll2
->adc_div
);
865 static int ov7251_set_exposure(struct ov7251
*ov7251
, s32 exposure
)
870 reg
= OV7251_AEC_EXPO_0
;
871 val
[0] = (exposure
& 0xf000) >> 12; /* goes to OV7251_AEC_EXPO_0 */
872 val
[1] = (exposure
& 0x0ff0) >> 4; /* goes to OV7251_AEC_EXPO_1 */
873 val
[2] = (exposure
& 0x000f) << 4; /* goes to OV7251_AEC_EXPO_2 */
875 return ov7251_write_seq_regs(ov7251
, reg
, val
, 3);
878 static int ov7251_set_gain(struct ov7251
*ov7251
, s32 gain
)
883 reg
= OV7251_AEC_AGC_ADJ_0
;
884 val
[0] = (gain
& 0x0300) >> 8; /* goes to OV7251_AEC_AGC_ADJ_0 */
885 val
[1] = gain
& 0xff; /* goes to OV7251_AEC_AGC_ADJ_1 */
887 return ov7251_write_seq_regs(ov7251
, reg
, val
, 2);
890 static int ov7251_set_register_array(struct ov7251
*ov7251
,
891 const struct reg_value
*settings
,
892 unsigned int num_settings
)
897 for (i
= 0; i
< num_settings
; ++i
, ++settings
) {
898 ret
= ov7251_write_reg(ov7251
, settings
->reg
, settings
->val
);
906 static int ov7251_set_power_on(struct device
*dev
)
908 struct i2c_client
*client
= container_of(dev
, struct i2c_client
, dev
);
909 struct v4l2_subdev
*sd
= i2c_get_clientdata(client
);
910 struct ov7251
*ov7251
= to_ov7251(sd
);
914 ret
= ov7251_regulators_enable(ov7251
);
918 ret
= clk_prepare_enable(ov7251
->xclk
);
920 dev_err(ov7251
->dev
, "clk prepare enable failed\n");
921 ov7251_regulators_disable(ov7251
);
925 gpiod_set_value_cansleep(ov7251
->enable_gpio
, 1);
927 /* wait at least 65536 external clock cycles */
928 wait_us
= DIV_ROUND_UP(65536 * 1000,
929 DIV_ROUND_UP(ov7251
->xclk_freq
, 1000));
930 usleep_range(wait_us
, wait_us
+ 1000);
932 ret
= ov7251_set_register_array(ov7251
,
933 ov7251_global_init_setting
,
934 ARRAY_SIZE(ov7251_global_init_setting
));
936 dev_err(ov7251
->dev
, "error during global init\n");
937 gpiod_set_value_cansleep(ov7251
->enable_gpio
, 0);
938 clk_disable_unprepare(ov7251
->xclk
);
939 ov7251_regulators_disable(ov7251
);
946 static int ov7251_set_power_off(struct device
*dev
)
948 struct i2c_client
*client
= container_of(dev
, struct i2c_client
, dev
);
949 struct v4l2_subdev
*sd
= i2c_get_clientdata(client
);
950 struct ov7251
*ov7251
= to_ov7251(sd
);
952 clk_disable_unprepare(ov7251
->xclk
);
953 gpiod_set_value_cansleep(ov7251
->enable_gpio
, 0);
954 ov7251_regulators_disable(ov7251
);
959 static int ov7251_set_hflip(struct ov7251
*ov7251
, s32 value
)
961 u8 val
= ov7251
->timing_format2
;
965 val
|= OV7251_TIMING_FORMAT2_MIRROR
;
967 val
&= ~OV7251_TIMING_FORMAT2_MIRROR
;
969 ret
= ov7251_write_reg(ov7251
, OV7251_TIMING_FORMAT2
, val
);
971 ov7251
->timing_format2
= val
;
976 static int ov7251_set_vflip(struct ov7251
*ov7251
, s32 value
)
978 u8 val
= ov7251
->timing_format1
;
982 val
|= OV7251_TIMING_FORMAT1_VFLIP
;
984 val
&= ~OV7251_TIMING_FORMAT1_VFLIP
;
986 ret
= ov7251_write_reg(ov7251
, OV7251_TIMING_FORMAT1
, val
);
988 ov7251
->timing_format1
= val
;
993 static int ov7251_set_test_pattern(struct ov7251
*ov7251
, s32 value
)
995 u8 val
= ov7251
->pre_isp_00
;
999 val
|= OV7251_PRE_ISP_00_TEST_PATTERN
;
1001 val
&= ~OV7251_PRE_ISP_00_TEST_PATTERN
;
1003 ret
= ov7251_write_reg(ov7251
, OV7251_PRE_ISP_00
, val
);
1005 ov7251
->pre_isp_00
= val
;
1010 static const char * const ov7251_test_pattern_menu
[] = {
1012 "Vertical Pattern Bars",
1015 static int ov7251_vts_configure(struct ov7251
*ov7251
, s32 vblank
)
1019 vts
[0] = ((ov7251
->current_mode
->height
+ vblank
) & 0xff00) >> 8;
1020 vts
[1] = ((ov7251
->current_mode
->height
+ vblank
) & 0x00ff);
1022 return ov7251_write_seq_regs(ov7251
, OV7251_TIMING_VTS_REG
, vts
, 2);
1025 static int ov7251_s_ctrl(struct v4l2_ctrl
*ctrl
)
1027 struct ov7251
*ov7251
= container_of(ctrl
->handler
,
1028 struct ov7251
, ctrls
);
1031 /* If VBLANK is altered we need to update exposure to compensate */
1032 if (ctrl
->id
== V4L2_CID_VBLANK
) {
1035 exposure_max
= ov7251
->current_mode
->height
+ ctrl
->val
-
1036 OV7251_INTEGRATION_MARGIN
;
1037 __v4l2_ctrl_modify_range(ov7251
->exposure
,
1038 ov7251
->exposure
->minimum
,
1040 ov7251
->exposure
->step
,
1041 min(ov7251
->exposure
->val
,
1045 /* v4l2_ctrl_lock() locks our mutex */
1047 if (!pm_runtime_get_if_in_use(ov7251
->dev
))
1051 case V4L2_CID_EXPOSURE
:
1052 ret
= ov7251_set_exposure(ov7251
, ctrl
->val
);
1055 ret
= ov7251_set_gain(ov7251
, ctrl
->val
);
1057 case V4L2_CID_TEST_PATTERN
:
1058 ret
= ov7251_set_test_pattern(ov7251
, ctrl
->val
);
1060 case V4L2_CID_HFLIP
:
1061 ret
= ov7251_set_hflip(ov7251
, ctrl
->val
);
1063 case V4L2_CID_VFLIP
:
1064 ret
= ov7251_set_vflip(ov7251
, ctrl
->val
);
1066 case V4L2_CID_VBLANK
:
1067 ret
= ov7251_vts_configure(ov7251
, ctrl
->val
);
1074 pm_runtime_put(ov7251
->dev
);
1079 static const struct v4l2_ctrl_ops ov7251_ctrl_ops
= {
1080 .s_ctrl
= ov7251_s_ctrl
,
1083 static int ov7251_enum_mbus_code(struct v4l2_subdev
*sd
,
1084 struct v4l2_subdev_state
*sd_state
,
1085 struct v4l2_subdev_mbus_code_enum
*code
)
1087 if (code
->index
> 0)
1090 code
->code
= MEDIA_BUS_FMT_Y10_1X10
;
1095 static int ov7251_enum_frame_size(struct v4l2_subdev
*subdev
,
1096 struct v4l2_subdev_state
*sd_state
,
1097 struct v4l2_subdev_frame_size_enum
*fse
)
1099 if (fse
->code
!= MEDIA_BUS_FMT_Y10_1X10
)
1102 if (fse
->index
>= ARRAY_SIZE(ov7251_mode_info_data
))
1105 fse
->min_width
= ov7251_mode_info_data
[fse
->index
].width
;
1106 fse
->max_width
= ov7251_mode_info_data
[fse
->index
].width
;
1107 fse
->min_height
= ov7251_mode_info_data
[fse
->index
].height
;
1108 fse
->max_height
= ov7251_mode_info_data
[fse
->index
].height
;
1113 static int ov7251_enum_frame_ival(struct v4l2_subdev
*subdev
,
1114 struct v4l2_subdev_state
*sd_state
,
1115 struct v4l2_subdev_frame_interval_enum
*fie
)
1117 unsigned int index
= fie
->index
;
1120 for (i
= 0; i
< ARRAY_SIZE(ov7251_mode_info_data
); i
++) {
1121 if (fie
->width
!= ov7251_mode_info_data
[i
].width
||
1122 fie
->height
!= ov7251_mode_info_data
[i
].height
)
1126 fie
->interval
= ov7251_mode_info_data
[i
].timeperframe
;
1134 static struct v4l2_mbus_framefmt
*
1135 __ov7251_get_pad_format(struct ov7251
*ov7251
,
1136 struct v4l2_subdev_state
*sd_state
,
1138 enum v4l2_subdev_format_whence which
)
1141 case V4L2_SUBDEV_FORMAT_TRY
:
1142 return v4l2_subdev_state_get_format(sd_state
, pad
);
1143 case V4L2_SUBDEV_FORMAT_ACTIVE
:
1144 return &ov7251
->fmt
;
1150 static int ov7251_get_format(struct v4l2_subdev
*sd
,
1151 struct v4l2_subdev_state
*sd_state
,
1152 struct v4l2_subdev_format
*format
)
1154 struct ov7251
*ov7251
= to_ov7251(sd
);
1156 mutex_lock(&ov7251
->lock
);
1157 format
->format
= *__ov7251_get_pad_format(ov7251
, sd_state
,
1160 mutex_unlock(&ov7251
->lock
);
1165 static struct v4l2_rect
*
1166 __ov7251_get_pad_crop(struct ov7251
*ov7251
,
1167 struct v4l2_subdev_state
*sd_state
,
1168 unsigned int pad
, enum v4l2_subdev_format_whence which
)
1171 case V4L2_SUBDEV_FORMAT_TRY
:
1172 return v4l2_subdev_state_get_crop(sd_state
, pad
);
1173 case V4L2_SUBDEV_FORMAT_ACTIVE
:
1174 return &ov7251
->crop
;
1180 static inline u32
avg_fps(const struct v4l2_fract
*t
)
1182 return (t
->denominator
+ (t
->numerator
>> 1)) / t
->numerator
;
1185 static const struct ov7251_mode_info
*
1186 ov7251_find_mode_by_ival(struct ov7251
*ov7251
, struct v4l2_fract
*timeperframe
)
1188 const struct ov7251_mode_info
*mode
= ov7251
->current_mode
;
1189 unsigned int fps_req
= avg_fps(timeperframe
);
1190 unsigned int max_dist_match
= (unsigned int) -1;
1191 unsigned int i
, n
= 0;
1193 for (i
= 0; i
< ARRAY_SIZE(ov7251_mode_info_data
); i
++) {
1195 unsigned int fps_tmp
;
1197 if (mode
->width
!= ov7251_mode_info_data
[i
].width
||
1198 mode
->height
!= ov7251_mode_info_data
[i
].height
)
1201 fps_tmp
= avg_fps(&ov7251_mode_info_data
[i
].timeperframe
);
1203 dist
= abs(fps_req
- fps_tmp
);
1205 if (dist
< max_dist_match
) {
1207 max_dist_match
= dist
;
1211 return &ov7251_mode_info_data
[n
];
1214 static int ov7251_set_format(struct v4l2_subdev
*sd
,
1215 struct v4l2_subdev_state
*sd_state
,
1216 struct v4l2_subdev_format
*format
)
1218 struct ov7251
*ov7251
= to_ov7251(sd
);
1219 struct v4l2_mbus_framefmt
*__format
;
1220 int vblank_max
, vblank_def
;
1221 struct v4l2_rect
*__crop
;
1222 const struct ov7251_mode_info
*new_mode
;
1225 mutex_lock(&ov7251
->lock
);
1227 __crop
= __ov7251_get_pad_crop(ov7251
, sd_state
, format
->pad
,
1230 new_mode
= v4l2_find_nearest_size(ov7251_mode_info_data
,
1231 ARRAY_SIZE(ov7251_mode_info_data
),
1233 format
->format
.width
, format
->format
.height
);
1235 __crop
->width
= new_mode
->width
;
1236 __crop
->height
= new_mode
->height
;
1238 if (format
->which
== V4L2_SUBDEV_FORMAT_ACTIVE
) {
1239 ret
= __v4l2_ctrl_modify_range(ov7251
->exposure
,
1240 1, new_mode
->exposure_max
,
1241 1, new_mode
->exposure_def
);
1245 ret
= __v4l2_ctrl_s_ctrl(ov7251
->exposure
,
1246 new_mode
->exposure_def
);
1250 ret
= __v4l2_ctrl_s_ctrl(ov7251
->gain
, 16);
1254 vblank_max
= OV7251_TIMING_MAX_VTS
- new_mode
->height
;
1255 vblank_def
= new_mode
->vts
- new_mode
->height
;
1256 ret
= __v4l2_ctrl_modify_range(ov7251
->vblank
,
1257 OV7251_TIMING_MIN_VTS
,
1258 vblank_max
, 1, vblank_def
);
1262 ov7251
->current_mode
= new_mode
;
1265 __format
= __ov7251_get_pad_format(ov7251
, sd_state
, format
->pad
,
1267 __format
->width
= __crop
->width
;
1268 __format
->height
= __crop
->height
;
1269 __format
->code
= MEDIA_BUS_FMT_Y10_1X10
;
1270 __format
->field
= V4L2_FIELD_NONE
;
1271 __format
->colorspace
= V4L2_COLORSPACE_SRGB
;
1272 __format
->ycbcr_enc
= V4L2_MAP_YCBCR_ENC_DEFAULT(__format
->colorspace
);
1273 __format
->quantization
= V4L2_MAP_QUANTIZATION_DEFAULT(true,
1274 __format
->colorspace
, __format
->ycbcr_enc
);
1275 __format
->xfer_func
= V4L2_MAP_XFER_FUNC_DEFAULT(__format
->colorspace
);
1277 format
->format
= *__format
;
1280 mutex_unlock(&ov7251
->lock
);
1285 static int ov7251_init_state(struct v4l2_subdev
*subdev
,
1286 struct v4l2_subdev_state
*sd_state
)
1288 struct v4l2_subdev_format fmt
= {
1289 .which
= sd_state
? V4L2_SUBDEV_FORMAT_TRY
1290 : V4L2_SUBDEV_FORMAT_ACTIVE
,
1297 ov7251_set_format(subdev
, sd_state
, &fmt
);
1302 static int ov7251_get_selection(struct v4l2_subdev
*sd
,
1303 struct v4l2_subdev_state
*sd_state
,
1304 struct v4l2_subdev_selection
*sel
)
1306 struct ov7251
*ov7251
= to_ov7251(sd
);
1308 switch (sel
->target
) {
1309 case V4L2_SEL_TGT_CROP_DEFAULT
:
1310 case V4L2_SEL_TGT_CROP
:
1311 mutex_lock(&ov7251
->lock
);
1312 sel
->r
= *__ov7251_get_pad_crop(ov7251
, sd_state
, sel
->pad
,
1314 mutex_unlock(&ov7251
->lock
);
1316 case V4L2_SEL_TGT_NATIVE_SIZE
:
1319 sel
->r
.width
= OV7251_NATIVE_WIDTH
;
1320 sel
->r
.height
= OV7251_NATIVE_HEIGHT
;
1322 case V4L2_SEL_TGT_CROP_BOUNDS
:
1323 sel
->r
.top
= OV7251_ACTIVE_START_TOP
;
1324 sel
->r
.left
= OV7251_ACTIVE_START_LEFT
;
1325 sel
->r
.width
= OV7251_ACTIVE_WIDTH
;
1326 sel
->r
.height
= OV7251_ACTIVE_HEIGHT
;
1335 static int ov7251_s_stream(struct v4l2_subdev
*subdev
, int enable
)
1337 struct ov7251
*ov7251
= to_ov7251(subdev
);
1340 mutex_lock(&ov7251
->lock
);
1343 ret
= pm_runtime_resume_and_get(ov7251
->dev
);
1345 mutex_unlock(&ov7251
->lock
);
1349 ret
= ov7251_pll_configure(ov7251
);
1351 dev_err(ov7251
->dev
, "error configuring PLLs\n");
1352 goto err_power_down
;
1355 ret
= ov7251_set_register_array(ov7251
,
1356 ov7251
->current_mode
->data
,
1357 ov7251
->current_mode
->data_size
);
1359 dev_err(ov7251
->dev
, "could not set mode %dx%d\n",
1360 ov7251
->current_mode
->width
,
1361 ov7251
->current_mode
->height
);
1362 goto err_power_down
;
1364 ret
= __v4l2_ctrl_handler_setup(&ov7251
->ctrls
);
1366 dev_err(ov7251
->dev
, "could not sync v4l2 controls\n");
1367 goto err_power_down
;
1369 ret
= ov7251_write_reg(ov7251
, OV7251_SC_MODE_SELECT
,
1370 OV7251_SC_MODE_SELECT_STREAMING
);
1372 goto err_power_down
;
1374 ret
= ov7251_write_reg(ov7251
, OV7251_SC_MODE_SELECT
,
1375 OV7251_SC_MODE_SELECT_SW_STANDBY
);
1376 pm_runtime_put(ov7251
->dev
);
1379 mutex_unlock(&ov7251
->lock
);
1383 pm_runtime_put(ov7251
->dev
);
1384 mutex_unlock(&ov7251
->lock
);
1388 static int ov7251_get_frame_interval(struct v4l2_subdev
*subdev
,
1389 struct v4l2_subdev_state
*sd_state
,
1390 struct v4l2_subdev_frame_interval
*fi
)
1392 struct ov7251
*ov7251
= to_ov7251(subdev
);
1395 * FIXME: Implement support for V4L2_SUBDEV_FORMAT_TRY, using the V4L2
1396 * subdev active state API.
1398 if (fi
->which
!= V4L2_SUBDEV_FORMAT_ACTIVE
)
1401 mutex_lock(&ov7251
->lock
);
1402 fi
->interval
= ov7251
->current_mode
->timeperframe
;
1403 mutex_unlock(&ov7251
->lock
);
1408 static int ov7251_set_frame_interval(struct v4l2_subdev
*subdev
,
1409 struct v4l2_subdev_state
*sd_state
,
1410 struct v4l2_subdev_frame_interval
*fi
)
1412 struct ov7251
*ov7251
= to_ov7251(subdev
);
1413 const struct ov7251_mode_info
*new_mode
;
1417 * FIXME: Implement support for V4L2_SUBDEV_FORMAT_TRY, using the V4L2
1418 * subdev active state API.
1420 if (fi
->which
!= V4L2_SUBDEV_FORMAT_ACTIVE
)
1423 mutex_lock(&ov7251
->lock
);
1424 new_mode
= ov7251_find_mode_by_ival(ov7251
, &fi
->interval
);
1426 if (new_mode
!= ov7251
->current_mode
) {
1427 ret
= __v4l2_ctrl_modify_range(ov7251
->exposure
,
1428 1, new_mode
->exposure_max
,
1429 1, new_mode
->exposure_def
);
1433 ret
= __v4l2_ctrl_s_ctrl(ov7251
->exposure
,
1434 new_mode
->exposure_def
);
1438 ret
= __v4l2_ctrl_s_ctrl(ov7251
->gain
, 16);
1442 ov7251
->current_mode
= new_mode
;
1445 fi
->interval
= ov7251
->current_mode
->timeperframe
;
1448 mutex_unlock(&ov7251
->lock
);
1453 static const struct v4l2_subdev_video_ops ov7251_video_ops
= {
1454 .s_stream
= ov7251_s_stream
,
1457 static const struct v4l2_subdev_pad_ops ov7251_subdev_pad_ops
= {
1458 .enum_mbus_code
= ov7251_enum_mbus_code
,
1459 .enum_frame_size
= ov7251_enum_frame_size
,
1460 .enum_frame_interval
= ov7251_enum_frame_ival
,
1461 .get_fmt
= ov7251_get_format
,
1462 .set_fmt
= ov7251_set_format
,
1463 .get_selection
= ov7251_get_selection
,
1464 .get_frame_interval
= ov7251_get_frame_interval
,
1465 .set_frame_interval
= ov7251_set_frame_interval
,
1468 static const struct v4l2_subdev_ops ov7251_subdev_ops
= {
1469 .video
= &ov7251_video_ops
,
1470 .pad
= &ov7251_subdev_pad_ops
,
1473 static const struct v4l2_subdev_internal_ops ov7251_internal_ops
= {
1474 .init_state
= ov7251_init_state
,
1477 static int ov7251_check_hwcfg(struct ov7251
*ov7251
)
1479 struct fwnode_handle
*fwnode
= dev_fwnode(ov7251
->dev
);
1480 struct v4l2_fwnode_endpoint bus_cfg
= {
1481 .bus_type
= V4L2_MBUS_CSI2_DPHY
,
1483 struct fwnode_handle
*endpoint
;
1487 endpoint
= fwnode_graph_get_next_endpoint(fwnode
, NULL
);
1489 return -EPROBE_DEFER
; /* could be provided by cio2-bridge */
1491 ret
= v4l2_fwnode_endpoint_alloc_parse(endpoint
, &bus_cfg
);
1492 fwnode_handle_put(endpoint
);
1494 return dev_err_probe(ov7251
->dev
, ret
,
1495 "parsing endpoint node failed\n");
1497 if (!bus_cfg
.nr_of_link_frequencies
) {
1498 ret
= dev_err_probe(ov7251
->dev
, -EINVAL
,
1499 "no link frequencies defined\n");
1500 goto out_free_bus_cfg
;
1503 for (i
= 0; i
< bus_cfg
.nr_of_link_frequencies
; i
++) {
1504 for (j
= 0; j
< ARRAY_SIZE(link_freq
); j
++)
1505 if (bus_cfg
.link_frequencies
[i
] == link_freq
[j
])
1508 if (j
< ARRAY_SIZE(link_freq
))
1512 if (i
== bus_cfg
.nr_of_link_frequencies
) {
1513 ret
= dev_err_probe(ov7251
->dev
, -EINVAL
,
1514 "no supported link freq found\n");
1515 goto out_free_bus_cfg
;
1518 ov7251
->link_freq_idx
= i
;
1521 v4l2_fwnode_endpoint_free(&bus_cfg
);
1526 static int ov7251_detect_chip(struct ov7251
*ov7251
)
1528 u8 chip_id_high
, chip_id_low
, chip_rev
;
1531 ret
= ov7251_read_reg(ov7251
, OV7251_CHIP_ID_HIGH
, &chip_id_high
);
1532 if (ret
< 0 || chip_id_high
!= OV7251_CHIP_ID_HIGH_BYTE
)
1533 return dev_err_probe(ov7251
->dev
, -ENODEV
,
1534 "could not read ID high\n");
1536 ret
= ov7251_read_reg(ov7251
, OV7251_CHIP_ID_LOW
, &chip_id_low
);
1537 if (ret
< 0 || chip_id_low
!= OV7251_CHIP_ID_LOW_BYTE
)
1538 return dev_err_probe(ov7251
->dev
, -ENODEV
,
1539 "could not read ID low\n");
1541 ret
= ov7251_read_reg(ov7251
, OV7251_SC_GP_IO_IN1
, &chip_rev
);
1543 return dev_err_probe(ov7251
->dev
, -ENODEV
,
1544 "could not read revision\n");
1547 dev_info(ov7251
->dev
,
1548 "OV7251 revision %x (%s) detected at address 0x%02x\n",
1550 chip_rev
== 0x4 ? "1A / 1B" :
1551 chip_rev
== 0x5 ? "1C / 1D" :
1552 chip_rev
== 0x6 ? "1E" :
1553 chip_rev
== 0x7 ? "1F" : "unknown",
1554 ov7251
->i2c_client
->addr
);
1559 static int ov7251_init_ctrls(struct ov7251
*ov7251
)
1561 int vblank_max
, vblank_def
;
1565 v4l2_ctrl_handler_init(&ov7251
->ctrls
, 7);
1566 ov7251
->ctrls
.lock
= &ov7251
->lock
;
1568 v4l2_ctrl_new_std(&ov7251
->ctrls
, &ov7251_ctrl_ops
,
1569 V4L2_CID_HFLIP
, 0, 1, 1, 0);
1570 v4l2_ctrl_new_std(&ov7251
->ctrls
, &ov7251_ctrl_ops
,
1571 V4L2_CID_VFLIP
, 0, 1, 1, 0);
1572 ov7251
->exposure
= v4l2_ctrl_new_std(&ov7251
->ctrls
, &ov7251_ctrl_ops
,
1573 V4L2_CID_EXPOSURE
, 1, 32, 1, 32);
1574 ov7251
->gain
= v4l2_ctrl_new_std(&ov7251
->ctrls
, &ov7251_ctrl_ops
,
1575 V4L2_CID_GAIN
, 16, 1023, 1, 16);
1576 v4l2_ctrl_new_std_menu_items(&ov7251
->ctrls
, &ov7251_ctrl_ops
,
1577 V4L2_CID_TEST_PATTERN
,
1578 ARRAY_SIZE(ov7251_test_pattern_menu
) - 1,
1579 0, 0, ov7251_test_pattern_menu
);
1581 pixel_rate
= pixel_rates
[ov7251
->link_freq_idx
];
1582 ov7251
->pixel_clock
= v4l2_ctrl_new_std(&ov7251
->ctrls
,
1584 V4L2_CID_PIXEL_RATE
,
1585 pixel_rate
, INT_MAX
,
1586 pixel_rate
, pixel_rate
);
1587 ov7251
->link_freq
= v4l2_ctrl_new_int_menu(&ov7251
->ctrls
,
1590 ARRAY_SIZE(link_freq
) - 1,
1591 ov7251
->link_freq_idx
,
1593 if (ov7251
->link_freq
)
1594 ov7251
->link_freq
->flags
|= V4L2_CTRL_FLAG_READ_ONLY
;
1595 if (ov7251
->pixel_clock
)
1596 ov7251
->pixel_clock
->flags
|= V4L2_CTRL_FLAG_READ_ONLY
;
1598 hblank
= OV7251_FIXED_PPL
- ov7251
->current_mode
->width
;
1599 ov7251
->hblank
= v4l2_ctrl_new_std(&ov7251
->ctrls
, &ov7251_ctrl_ops
,
1600 V4L2_CID_HBLANK
, hblank
, hblank
, 1,
1603 ov7251
->hblank
->flags
|= V4L2_CTRL_FLAG_READ_ONLY
;
1605 vblank_max
= OV7251_TIMING_MAX_VTS
- ov7251
->current_mode
->height
;
1606 vblank_def
= ov7251
->current_mode
->vts
- ov7251
->current_mode
->height
;
1607 ov7251
->vblank
= v4l2_ctrl_new_std(&ov7251
->ctrls
, &ov7251_ctrl_ops
,
1609 OV7251_TIMING_MIN_VTS
, vblank_max
, 1,
1612 ov7251
->sd
.ctrl_handler
= &ov7251
->ctrls
;
1614 if (ov7251
->ctrls
.error
) {
1615 v4l2_ctrl_handler_free(&ov7251
->ctrls
);
1616 return ov7251
->ctrls
.error
;
1622 static int ov7251_probe(struct i2c_client
*client
)
1624 struct device
*dev
= &client
->dev
;
1625 struct ov7251
*ov7251
;
1626 unsigned int rate
= 0, clk_rate
= 0;
1630 ov7251
= devm_kzalloc(dev
, sizeof(struct ov7251
), GFP_KERNEL
);
1634 ov7251
->i2c_client
= client
;
1637 ret
= ov7251_check_hwcfg(ov7251
);
1641 /* get system clock (xclk) */
1642 ov7251
->xclk
= devm_clk_get_optional(dev
, NULL
);
1643 if (IS_ERR(ov7251
->xclk
))
1644 return dev_err_probe(dev
, PTR_ERR(ov7251
->xclk
),
1645 "could not get xclk");
1648 * We could have either a 24MHz or 19.2MHz clock rate from either DT or
1649 * ACPI. We also need to support the IPU3 case which will have both an
1650 * external clock AND a clock-frequency property.
1652 ret
= fwnode_property_read_u32(dev_fwnode(dev
), "clock-frequency",
1654 if (ret
&& !ov7251
->xclk
)
1655 return dev_err_probe(dev
, ret
, "invalid clock config\n");
1657 clk_rate
= clk_get_rate(ov7251
->xclk
);
1658 ov7251
->xclk_freq
= clk_rate
? clk_rate
: rate
;
1660 if (ov7251
->xclk_freq
== 0)
1661 return dev_err_probe(dev
, -EINVAL
, "invalid clock frequency\n");
1663 if (!ret
&& ov7251
->xclk
) {
1664 ret
= clk_set_rate(ov7251
->xclk
, rate
);
1666 return dev_err_probe(dev
, ret
,
1667 "failed to set clock rate\n");
1670 for (i
= 0; i
< ARRAY_SIZE(supported_xclk_rates
); i
++)
1671 if (ov7251
->xclk_freq
== supported_xclk_rates
[i
])
1674 if (i
== ARRAY_SIZE(supported_xclk_rates
))
1675 return dev_err_probe(dev
, -EINVAL
,
1676 "clock rate %u Hz is unsupported\n",
1679 ov7251
->pll_cfgs
= ov7251_pll_cfgs
[i
];
1681 ov7251
->io_regulator
= devm_regulator_get(dev
, "vdddo");
1682 if (IS_ERR(ov7251
->io_regulator
)) {
1683 dev_err(dev
, "cannot get io regulator\n");
1684 return PTR_ERR(ov7251
->io_regulator
);
1687 ov7251
->core_regulator
= devm_regulator_get(dev
, "vddd");
1688 if (IS_ERR(ov7251
->core_regulator
)) {
1689 dev_err(dev
, "cannot get core regulator\n");
1690 return PTR_ERR(ov7251
->core_regulator
);
1693 ov7251
->analog_regulator
= devm_regulator_get(dev
, "vdda");
1694 if (IS_ERR(ov7251
->analog_regulator
)) {
1695 dev_err(dev
, "cannot get analog regulator\n");
1696 return PTR_ERR(ov7251
->analog_regulator
);
1699 ov7251
->enable_gpio
= devm_gpiod_get(dev
, "enable", GPIOD_OUT_HIGH
);
1700 if (IS_ERR(ov7251
->enable_gpio
)) {
1701 dev_err(dev
, "cannot get enable gpio\n");
1702 return PTR_ERR(ov7251
->enable_gpio
);
1705 mutex_init(&ov7251
->lock
);
1707 ov7251
->current_mode
= &ov7251_mode_info_data
[0];
1708 ret
= ov7251_init_ctrls(ov7251
);
1710 dev_err_probe(dev
, ret
, "error during v4l2 ctrl init\n");
1714 v4l2_i2c_subdev_init(&ov7251
->sd
, client
, &ov7251_subdev_ops
);
1715 ov7251
->sd
.internal_ops
= &ov7251_internal_ops
;
1716 ov7251
->sd
.flags
|= V4L2_SUBDEV_FL_HAS_DEVNODE
;
1717 ov7251
->pad
.flags
= MEDIA_PAD_FL_SOURCE
;
1718 ov7251
->sd
.dev
= &client
->dev
;
1719 ov7251
->sd
.entity
.function
= MEDIA_ENT_F_CAM_SENSOR
;
1721 ret
= media_entity_pads_init(&ov7251
->sd
.entity
, 1, &ov7251
->pad
);
1723 dev_err(dev
, "could not register media entity\n");
1727 ret
= ov7251_set_power_on(ov7251
->dev
);
1731 ret
= ov7251_detect_chip(ov7251
);
1735 pm_runtime_set_active(&client
->dev
);
1736 pm_runtime_get_noresume(&client
->dev
);
1737 pm_runtime_enable(&client
->dev
);
1739 ret
= ov7251_read_reg(ov7251
, OV7251_PRE_ISP_00
,
1740 &ov7251
->pre_isp_00
);
1742 dev_err(dev
, "could not read test pattern value\n");
1744 goto err_pm_runtime
;
1747 ret
= ov7251_read_reg(ov7251
, OV7251_TIMING_FORMAT1
,
1748 &ov7251
->timing_format1
);
1750 dev_err(dev
, "could not read vflip value\n");
1752 goto err_pm_runtime
;
1755 ret
= ov7251_read_reg(ov7251
, OV7251_TIMING_FORMAT2
,
1756 &ov7251
->timing_format2
);
1758 dev_err(dev
, "could not read hflip value\n");
1760 goto err_pm_runtime
;
1763 pm_runtime_set_autosuspend_delay(&client
->dev
, 1000);
1764 pm_runtime_use_autosuspend(&client
->dev
);
1765 pm_runtime_put_autosuspend(&client
->dev
);
1767 ret
= v4l2_async_register_subdev(&ov7251
->sd
);
1769 dev_err(dev
, "could not register v4l2 device\n");
1773 ov7251_init_state(&ov7251
->sd
, NULL
);
1778 pm_runtime_disable(ov7251
->dev
);
1779 pm_runtime_put_noidle(ov7251
->dev
);
1781 ov7251_set_power_off(ov7251
->dev
);
1783 media_entity_cleanup(&ov7251
->sd
.entity
);
1785 v4l2_ctrl_handler_free(&ov7251
->ctrls
);
1787 mutex_destroy(&ov7251
->lock
);
1792 static void ov7251_remove(struct i2c_client
*client
)
1794 struct v4l2_subdev
*sd
= i2c_get_clientdata(client
);
1795 struct ov7251
*ov7251
= to_ov7251(sd
);
1797 v4l2_async_unregister_subdev(&ov7251
->sd
);
1798 media_entity_cleanup(&ov7251
->sd
.entity
);
1799 v4l2_ctrl_handler_free(&ov7251
->ctrls
);
1800 mutex_destroy(&ov7251
->lock
);
1802 pm_runtime_disable(ov7251
->dev
);
1803 if (!pm_runtime_status_suspended(ov7251
->dev
))
1804 ov7251_set_power_off(ov7251
->dev
);
1805 pm_runtime_set_suspended(ov7251
->dev
);
1808 static const struct dev_pm_ops ov7251_pm_ops
= {
1809 SET_RUNTIME_PM_OPS(ov7251_set_power_off
, ov7251_set_power_on
, NULL
)
1812 static const struct of_device_id ov7251_of_match
[] = {
1813 { .compatible
= "ovti,ov7251" },
1816 MODULE_DEVICE_TABLE(of
, ov7251_of_match
);
1818 static const struct acpi_device_id ov7251_acpi_match
[] = {
1822 MODULE_DEVICE_TABLE(acpi
, ov7251_acpi_match
);
1824 static struct i2c_driver ov7251_i2c_driver
= {
1826 .of_match_table
= ov7251_of_match
,
1827 .acpi_match_table
= ov7251_acpi_match
,
1829 .pm
= &ov7251_pm_ops
,
1831 .probe
= ov7251_probe
,
1832 .remove
= ov7251_remove
,
1835 module_i2c_driver(ov7251_i2c_driver
);
1837 MODULE_DESCRIPTION("Omnivision OV7251 Camera Driver");
1838 MODULE_AUTHOR("Todor Tomov <todor.tomov@linaro.org>");
1839 MODULE_LICENSE("GPL v2");