31 #include <linux/module.h>
32 #include <linux/types.h>
33 #include <linux/slab.h>
35 #include <asm/uaccess.h>
36 #include <linux/i2c.h>
37 #include <linux/videodev2.h>
54 unsigned char reg[128];
65 static char *inputs[] = {
"pass_through",
"play_back" };
77 struct adv7170 *encoder = to_adv7170(sd);
91 const u8 *
data,
unsigned int len)
94 struct adv7170 *encoder = to_adv7170(sd);
107 block_data[block_len++] = reg = data[0];
109 block_data[block_len++] =
110 encoder->
reg[reg++] = data[1];
113 }
while (len >= 2 && data[0] == reg && block_len < 32);
122 ret = adv7170_write(sd, reg, *data++);
139 static const unsigned char init_NTSC[] = {
168 static const unsigned char init_PAL[] = {
200 struct adv7170 *encoder = to_adv7170(sd);
202 v4l2_dbg(1,
debug, sd,
"set norm %llx\n", (
unsigned long long)std);
205 adv7170_write_block(sd, init_NTSC,
sizeof(init_NTSC));
206 if (encoder->
input == 0)
207 adv7170_write(sd, 0x02, 0x0e);
209 adv7170_write(sd, 0x07,
TR0MODE);
211 adv7170_write_block(sd, init_PAL,
sizeof(init_PAL));
212 if (encoder->
input == 0)
213 adv7170_write(sd, 0x02, 0x0e);
215 adv7170_write(sd, 0x07,
TR0MODE);
218 (
unsigned long long)std);
221 v4l2_dbg(1,
debug, sd,
"switched to %llx\n", (
unsigned long long)std);
226 static int adv7170_s_routing(
struct v4l2_subdev *sd,
229 struct adv7170 *encoder = to_adv7170(sd);
236 input == 0 ?
"decoder" :
"ZR36060");
240 adv7170_write(sd, 0x01, 0x20);
241 adv7170_write(sd, 0x08,
TR1CAPT);
242 adv7170_write(sd, 0x02, 0x0e);
244 adv7170_write(sd, 0x07,
TR0MODE);
249 adv7170_write(sd, 0x01, 0x00);
250 adv7170_write(sd, 0x08,
TR1PLAY);
251 adv7170_write(sd, 0x02, 0x08);
253 adv7170_write(sd, 0x07,
TR0MODE);
272 *code = adv7170_codes[
index];
277 struct v4l2_mbus_framefmt *mf)
279 u8 val = adv7170_read(sd, 0x7);
281 if ((val & 0x40) == (1 << 6))
295 struct v4l2_mbus_framefmt *mf)
297 u8 val = adv7170_read(sd, 0x7);
311 "illegal v4l2_mbus_framefmt code: %d\n", mf->code);
315 ret = adv7170_write(sd, 0x7, val);
322 struct i2c_client *client = v4l2_get_subdevdata(sd);
330 .g_chip_ident = adv7170_g_chip_ident,
334 .s_std_output = adv7170_s_std_output,
335 .s_routing = adv7170_s_routing,
336 .s_mbus_fmt = adv7170_s_fmt,
337 .g_mbus_fmt = adv7170_g_fmt,
338 .enum_mbus_fmt = adv7170_enum_fmt,
342 .core = &adv7170_core_ops,
343 .video = &adv7170_video_ops,
348 static int adv7170_probe(
struct i2c_client *client,
359 v4l_info(client,
"chip found @ 0x%x (%s)\n",
370 i = adv7170_write_block(sd, init_NTSC,
sizeof(init_NTSC));
373 i = adv7170_write(sd, 0x07,
TR0MODE);
374 i = adv7170_read(sd, 0x12);
382 static int adv7170_remove(
struct i2c_client *client)
384 struct v4l2_subdev *sd = i2c_get_clientdata(client);
387 kfree(to_adv7170(sd));
405 .probe = adv7170_probe,
406 .remove = adv7170_remove,
407 .id_table = adv7170_id,