27 #include <linux/module.h>
28 #include <linux/types.h>
29 #include <linux/slab.h>
31 #include <asm/uaccess.h>
32 #include <linux/i2c.h>
33 #include <linux/videodev2.h>
41 #define I2C_ADV7175 0xd4
42 #define I2C_ADV7176 0x54
62 static char *inputs[] = {
"pass_through",
"play_back",
"color_bar" };
86 const u8 *
data,
unsigned int len)
101 block_data[block_len++] = reg = data[0];
103 block_data[block_len++] = data[1];
107 }
while (len >= 2 && data[0] == reg && block_len < 32);
116 ret = adv7175_write(sd, reg, *data++);
131 adv7175_write(sd, 0x02, 0x00);
133 adv7175_write(sd, 0x02, 0x55);
135 adv7175_write(sd, 0x03, 0x55);
136 adv7175_write(sd, 0x04, 0x55);
137 adv7175_write(sd, 0x05, 0x25);
154 static const unsigned char init_common[] = {
177 static const unsigned char init_pal[] = {
187 static const unsigned char init_ntsc[] = {
200 adv7175_write_block(sd, init_common,
sizeof(init_common));
202 adv7175_write(sd, 0x07,
TR0MODE);
208 struct adv7175 *encoder = to_adv7175(sd);
211 adv7175_write_block(sd, init_ntsc,
sizeof(init_ntsc));
212 if (encoder->
input == 0)
213 adv7175_write(sd, 0x0d, 0x4f);
215 adv7175_write(sd, 0x07,
TR0MODE);
217 adv7175_write_block(sd, init_pal,
sizeof(init_pal));
218 if (encoder->
input == 0)
219 adv7175_write(sd, 0x0d, 0x4f);
221 adv7175_write(sd, 0x07,
TR0MODE);
229 adv7175_write_block(sd, init_pal,
sizeof(init_pal));
230 if (encoder->
input == 0)
231 adv7175_write(sd, 0x0d, 0x49);
233 adv7175_write(sd, 0x07,
TR0MODE);
236 (
unsigned long long)std);
239 v4l2_dbg(1,
debug, sd,
"switched to %llx\n", (
unsigned long long)std);
244 static int adv7175_s_routing(
struct v4l2_subdev *sd,
247 struct adv7175 *encoder = to_adv7175(sd);
255 adv7175_write(sd, 0x01, 0x00);
257 if (encoder->
norm & V4L2_STD_NTSC)
258 set_subcarrier_freq(sd, 1);
260 adv7175_write(sd, 0x0c,
TR1CAPT);
261 if (encoder->
norm & V4L2_STD_SECAM)
262 adv7175_write(sd, 0x0d, 0x49);
264 adv7175_write(sd, 0x0d, 0x4f);
266 adv7175_write(sd, 0x07,
TR0MODE);
271 adv7175_write(sd, 0x01, 0x00);
273 if (encoder->
norm & V4L2_STD_NTSC)
274 set_subcarrier_freq(sd, 0);
276 adv7175_write(sd, 0x0c,
TR1PLAY);
277 adv7175_write(sd, 0x0d, 0x49);
279 adv7175_write(sd, 0x07,
TR0MODE);
284 adv7175_write(sd, 0x01, 0x80);
286 if (encoder->
norm & V4L2_STD_NTSC)
287 set_subcarrier_freq(sd, 0);
289 adv7175_write(sd, 0x0d, 0x49);
291 adv7175_write(sd, 0x07,
TR0MODE);
310 *code = adv7175_codes[
index];
315 struct v4l2_mbus_framefmt *mf)
317 u8 val = adv7175_read(sd, 0x7);
319 if ((val & 0x40) == (1 << 6))
333 struct v4l2_mbus_framefmt *mf)
335 u8 val = adv7175_read(sd, 0x7);
349 "illegal v4l2_mbus_framefmt code: %d\n", mf->code);
353 ret = adv7175_write(sd, 0x7, val);
360 struct i2c_client *client = v4l2_get_subdevdata(sd);
365 static int adv7175_s_power(
struct v4l2_subdev *sd,
int on)
368 adv7175_write(sd, 0x01, 0x00);
370 adv7175_write(sd, 0x01, 0x78);
378 .g_chip_ident = adv7175_g_chip_ident,
379 .init = adv7175_init,
380 .s_power = adv7175_s_power,
384 .s_std_output = adv7175_s_std_output,
385 .s_routing = adv7175_s_routing,
386 .s_mbus_fmt = adv7175_s_fmt,
387 .g_mbus_fmt = adv7175_g_fmt,
388 .enum_mbus_fmt = adv7175_enum_fmt,
392 .core = &adv7175_core_ops,
393 .video = &adv7175_video_ops,
398 static int adv7175_probe(
struct i2c_client *client,
409 v4l_info(client,
"chip found @ 0x%x (%s)\n",
420 i = adv7175_write_block(sd, init_common,
sizeof(init_common));
423 i = adv7175_write(sd, 0x07,
TR0MODE);
424 i = adv7175_read(sd, 0x12);
432 static int adv7175_remove(
struct i2c_client *client)
434 struct v4l2_subdev *sd = i2c_get_clientdata(client);
437 kfree(to_adv7175(sd));
455 .probe = adv7175_probe,
456 .remove = adv7175_remove,
457 .id_table = adv7175_id,