19 #include <linux/module.h>
21 #include <linux/errno.h>
22 #include <linux/kernel.h>
24 #include <linux/i2c.h>
25 #include <linux/slab.h>
27 #include <linux/videodev2.h>
33 #define ADV7180_INPUT_CONTROL_REG 0x00
34 #define ADV7180_INPUT_CONTROL_AD_PAL_BG_NTSC_J_SECAM 0x00
35 #define ADV7180_INPUT_CONTROL_AD_PAL_BG_NTSC_J_SECAM_PED 0x10
36 #define ADV7180_INPUT_CONTROL_AD_PAL_N_NTSC_J_SECAM 0x20
37 #define ADV7180_INPUT_CONTROL_AD_PAL_N_NTSC_M_SECAM 0x30
38 #define ADV7180_INPUT_CONTROL_NTSC_J 0x40
39 #define ADV7180_INPUT_CONTROL_NTSC_M 0x50
40 #define ADV7180_INPUT_CONTROL_PAL60 0x60
41 #define ADV7180_INPUT_CONTROL_NTSC_443 0x70
42 #define ADV7180_INPUT_CONTROL_PAL_BG 0x80
43 #define ADV7180_INPUT_CONTROL_PAL_N 0x90
44 #define ADV7180_INPUT_CONTROL_PAL_M 0xa0
45 #define ADV7180_INPUT_CONTROL_PAL_M_PED 0xb0
46 #define ADV7180_INPUT_CONTROL_PAL_COMB_N 0xc0
47 #define ADV7180_INPUT_CONTROL_PAL_COMB_N_PED 0xd0
48 #define ADV7180_INPUT_CONTROL_PAL_SECAM 0xe0
49 #define ADV7180_INPUT_CONTROL_PAL_SECAM_PED 0xf0
50 #define ADV7180_INPUT_CONTROL_INSEL_MASK 0x0f
52 #define ADV7180_EXTENDED_OUTPUT_CONTROL_REG 0x04
53 #define ADV7180_EXTENDED_OUTPUT_CONTROL_NTSCDIS 0xC5
55 #define ADV7180_AUTODETECT_ENABLE_REG 0x07
56 #define ADV7180_AUTODETECT_DEFAULT 0x7f
58 #define ADV7180_CON_REG 0x08
59 #define ADV7180_CON_MIN 0
60 #define ADV7180_CON_DEF 128
61 #define ADV7180_CON_MAX 255
63 #define ADV7180_BRI_REG 0x0a
64 #define ADV7180_BRI_MIN -128
65 #define ADV7180_BRI_DEF 0
66 #define ADV7180_BRI_MAX 127
68 #define ADV7180_HUE_REG 0x0b
69 #define ADV7180_HUE_MIN -127
70 #define ADV7180_HUE_DEF 0
71 #define ADV7180_HUE_MAX 128
73 #define ADV7180_ADI_CTRL_REG 0x0e
74 #define ADV7180_ADI_CTRL_IRQ_SPACE 0x20
76 #define ADV7180_PWR_MAN_REG 0x0f
77 #define ADV7180_PWR_MAN_ON 0x04
78 #define ADV7180_PWR_MAN_OFF 0x24
79 #define ADV7180_PWR_MAN_RES 0x80
81 #define ADV7180_STATUS1_REG 0x10
82 #define ADV7180_STATUS1_IN_LOCK 0x01
83 #define ADV7180_STATUS1_AUTOD_MASK 0x70
84 #define ADV7180_STATUS1_AUTOD_NTSM_M_J 0x00
85 #define ADV7180_STATUS1_AUTOD_NTSC_4_43 0x10
86 #define ADV7180_STATUS1_AUTOD_PAL_M 0x20
87 #define ADV7180_STATUS1_AUTOD_PAL_60 0x30
88 #define ADV7180_STATUS1_AUTOD_PAL_B_G 0x40
89 #define ADV7180_STATUS1_AUTOD_SECAM 0x50
90 #define ADV7180_STATUS1_AUTOD_PAL_COMB 0x60
91 #define ADV7180_STATUS1_AUTOD_SECAM_525 0x70
93 #define ADV7180_IDENT_REG 0x11
94 #define ADV7180_ID_7180 0x18
96 #define ADV7180_ICONF1_ADI 0x40
97 #define ADV7180_ICONF1_ACTIVE_LOW 0x01
98 #define ADV7180_ICONF1_PSYNC_ONLY 0x10
99 #define ADV7180_ICONF1_ACTIVE_TO_CLR 0xC0
101 #define ADV7180_SD_SAT_CB_REG 0xe3
102 #define ADV7180_SD_SAT_CR_REG 0xe4
103 #define ADV7180_SAT_MIN 0
104 #define ADV7180_SAT_DEF 128
105 #define ADV7180_SAT_MAX 255
107 #define ADV7180_IRQ1_LOCK 0x01
108 #define ADV7180_IRQ1_UNLOCK 0x02
109 #define ADV7180_ISR1_ADI 0x42
110 #define ADV7180_ICR1_ADI 0x43
111 #define ADV7180_IMR1_ADI 0x44
112 #define ADV7180_IMR2_ADI 0x48
113 #define ADV7180_IRQ3_AD_CHANGE 0x08
114 #define ADV7180_ISR3_ADI 0x4A
115 #define ADV7180_ICR3_ADI 0x4B
116 #define ADV7180_IMR3_ADI 0x4C
117 #define ADV7180_IMR4_ADI 0x50
119 #define ADV7180_NTSC_V_BIT_END_REG 0xE6
120 #define ADV7180_NTSC_V_BIT_END_MANUAL_NVEND 0x4F
132 #define to_adv7180_sd(_ctrl) (&container_of(_ctrl->handler, \
133 struct adv7180_state, \
200 *status = adv7180_status_to_v4l2(status1);
202 *std = adv7180_std_to_v4l2(status1);
223 err = __adv7180_status(v4l2_get_subdevdata(sd),
NULL, std);
234 struct i2c_client *client = v4l2_get_subdevdata(sd);
250 ret &= ~ADV7180_INPUT_CONTROL_INSEL_MASK;
259 static int adv7180_g_input_status(
struct v4l2_subdev *sd,
u32 *status)
266 ret = __adv7180_status(v4l2_get_subdevdata(sd), status,
NULL);
271 static int adv7180_g_chip_ident(
struct v4l2_subdev *sd,
274 struct i2c_client *client = v4l2_get_subdevdata(sd);
282 struct i2c_client *client = v4l2_get_subdevdata(sd);
299 ret = v4l2_std_to_adv7180(std);
322 struct i2c_client *client = v4l2_get_subdevdata(sd);
361 .s_ctrl = adv7180_s_ctrl,
364 static int adv7180_init_controls(
struct adv7180_state *state)
391 static void adv7180_exit_controls(
struct adv7180_state *state)
397 .querystd = adv7180_querystd,
398 .g_input_status = adv7180_g_input_status,
399 .s_routing = adv7180_s_routing,
403 .g_chip_ident = adv7180_g_chip_ident,
404 .s_std = adv7180_s_std,
411 .core = &adv7180_core_ops,
412 .video = &adv7180_video_ops,
419 struct i2c_client *client = v4l2_get_subdevdata(&state->
sd);
469 ret = v4l2_std_to_adv7180(state->
curr_norm);
498 if (state->
irq > 0) {
554 v4l_info(client,
"chip found @ 0x%02x (%s)\n",
571 ret = adv7180_init_controls(state);
573 goto err_unreg_subdev;
574 ret = init_device(client, state);
580 adv7180_exit_controls(state);
592 struct v4l2_subdev *sd = i2c_get_clientdata(client);
595 if (state->
irq > 0) {
630 static int adv7180_resume(
struct i2c_client *client)
632 struct v4l2_subdev *sd = i2c_get_clientdata(client);
640 ret = init_device(client, state);
652 .name = KBUILD_MODNAME,
654 .probe = adv7180_probe,
657 .suspend = adv7180_suspend,
658 .resume = adv7180_resume,
660 .id_table = adv7180_id,