21 #include <linux/errno.h>
23 #include <linux/i2c.h>
25 #include <linux/module.h>
26 #include <linux/slab.h>
27 #include <linux/types.h>
28 #include <linux/videodev2.h>
46 struct v4l2_mbus_framefmt
fmt;
53 static const unsigned char adv7183_init_regs[] = {
101 const unsigned char *
regs,
unsigned int num)
104 unsigned int cnt = 0;
107 v4l2_err(sd,
"invalid regs array\n");
116 adv7183_write(sd, reg, data);
121 static int adv7183_log_status(
struct v4l2_subdev *sd)
123 struct adv7183 *decoder = to_adv7183(sd);
125 v4l2_info(sd,
"adv7183: Input control = 0x%02x\n",
127 v4l2_info(sd,
"adv7183: Video selection = 0x%02x\n",
129 v4l2_info(sd,
"adv7183: Output control = 0x%02x\n",
131 v4l2_info(sd,
"adv7183: Extended output control = 0x%02x\n",
133 v4l2_info(sd,
"adv7183: Autodetect enable = 0x%02x\n",
135 v4l2_info(sd,
"adv7183: Contrast = 0x%02x\n",
137 v4l2_info(sd,
"adv7183: Brightness = 0x%02x\n",
141 v4l2_info(sd,
"adv7183: Default value Y = 0x%02x\n",
143 v4l2_info(sd,
"adv7183: Default value C = 0x%02x\n",
145 v4l2_info(sd,
"adv7183: ADI control = 0x%02x\n",
147 v4l2_info(sd,
"adv7183: Power Management = 0x%02x\n",
149 v4l2_info(sd,
"adv7183: Status 1 2 and 3 = 0x%02x 0x%02x 0x%02x\n",
153 v4l2_info(sd,
"adv7183: Ident = 0x%02x\n",
155 v4l2_info(sd,
"adv7183: Analog clamp control = 0x%02x\n",
157 v4l2_info(sd,
"adv7183: Digital clamp control 1 = 0x%02x\n",
159 v4l2_info(sd,
"adv7183: Shaping filter control 1 and 2 = 0x%02x 0x%02x\n",
162 v4l2_info(sd,
"adv7183: Comb filter control = 0x%02x\n",
164 v4l2_info(sd,
"adv7183: ADI control 2 = 0x%02x\n",
166 v4l2_info(sd,
"adv7183: Pixel delay control = 0x%02x\n",
168 v4l2_info(sd,
"adv7183: Misc gain control = 0x%02x\n",
170 v4l2_info(sd,
"adv7183: AGC mode control = 0x%02x\n",
172 v4l2_info(sd,
"adv7183: Chroma gain control 1 and 2 = 0x%02x 0x%02x\n",
175 v4l2_info(sd,
"adv7183: Luma gain control 1 and 2 = 0x%02x 0x%02x\n",
178 v4l2_info(sd,
"adv7183: Vsync field control 1 2 and 3 = 0x%02x 0x%02x 0x%02x\n",
182 v4l2_info(sd,
"adv7183: Hsync positon control 1 2 and 3 = 0x%02x 0x%02x 0x%02x\n",
186 v4l2_info(sd,
"adv7183: Polarity = 0x%02x\n",
188 v4l2_info(sd,
"adv7183: ADC control = 0x%02x\n",
190 v4l2_info(sd,
"adv7183: SD offset Cb and Cr = 0x%02x 0x%02x\n",
193 v4l2_info(sd,
"adv7183: SD saturation Cb and Cr = 0x%02x 0x%02x\n",
196 v4l2_info(sd,
"adv7183: Drive strength = 0x%02x\n",
204 struct adv7183 *decoder = to_adv7183(sd);
212 struct adv7183 *decoder = to_adv7183(sd);
252 static int adv7183_s_routing(
struct v4l2_subdev *sd,
255 struct adv7183 *decoder = to_adv7183(sd);
261 if (input != decoder->
input) {
316 if (output != decoder->
output) {
364 struct adv7183 *decoder = to_adv7183(sd);
376 switch ((reg >> 0x4) & 0x7) {
407 adv7183_s_std(sd, decoder->
std);
434 static int adv7183_try_mbus_fmt(
struct v4l2_subdev *sd,
435 struct v4l2_mbus_framefmt *
fmt)
437 struct adv7183 *decoder = to_adv7183(sd);
453 static int adv7183_s_mbus_fmt(
struct v4l2_subdev *sd,
454 struct v4l2_mbus_framefmt *fmt)
456 struct adv7183 *decoder = to_adv7183(sd);
458 adv7183_try_mbus_fmt(sd, fmt);
463 static int adv7183_g_mbus_fmt(
struct v4l2_subdev *sd,
464 struct v4l2_mbus_framefmt *fmt)
466 struct adv7183 *decoder = to_adv7183(sd);
474 struct adv7183 *decoder = to_adv7183(sd);
484 static int adv7183_g_chip_ident(
struct v4l2_subdev *sd,
496 #ifdef CONFIG_VIDEO_ADV_DEBUG
505 reg->
val = adv7183_read(sd, reg->
reg & 0xff);
512 struct i2c_client *client = v4l2_get_subdevdata(sd);
518 adv7183_write(sd, reg->
reg & 0xff, reg->
val & 0xff);
524 .s_ctrl = adv7183_s_ctrl,
528 .log_status = adv7183_log_status,
529 .g_std = adv7183_g_std,
530 .s_std = adv7183_s_std,
531 .reset = adv7183_reset,
532 .g_chip_ident = adv7183_g_chip_ident,
533 #ifdef CONFIG_VIDEO_ADV_DEBUG
534 .g_register = adv7183_g_register,
535 .s_register = adv7183_s_register,
540 .s_routing = adv7183_s_routing,
541 .querystd = adv7183_querystd,
542 .g_input_status = adv7183_g_input_status,
543 .enum_mbus_fmt = adv7183_enum_mbus_fmt,
544 .try_mbus_fmt = adv7183_try_mbus_fmt,
545 .s_mbus_fmt = adv7183_s_mbus_fmt,
546 .g_mbus_fmt = adv7183_g_mbus_fmt,
547 .s_stream = adv7183_s_stream,
551 .core = &adv7183_core_ops,
552 .video = &adv7183_video_ops,
555 static int adv7183_probe(
struct i2c_client *client,
562 struct v4l2_mbus_framefmt fmt;
563 const unsigned *pin_array;
569 v4l_info(client,
"chip found @ 0x%02x (%s)\n",
572 pin_array = client->
dev.platform_data;
573 if (pin_array ==
NULL)
581 decoder->
oe_pin = pin_array[1];
586 goto err_free_decoder;
590 v4l_err(client,
"failed to request GPIO %d\n", decoder->
oe_pin);
631 adv7183_writeregs(sd, adv7183_init_regs,
ARRAY_SIZE(adv7183_init_regs));
632 adv7183_s_std(sd, decoder->
std);
635 adv7183_s_mbus_fmt(sd, &fmt);
654 static int adv7183_remove(
struct i2c_client *client)
656 struct v4l2_subdev *sd = i2c_get_clientdata(client);
657 struct adv7183 *decoder = to_adv7183(sd);
679 .probe = adv7183_probe,
681 .id_table = adv7183_id,
684 static __init int adv7183_init(
void)
686 return i2c_add_driver(&adv7183_driver);
689 static __exit void adv7183_exit(
void)