18 #include <linux/kernel.h>
20 #include <linux/ctype.h>
21 #include <linux/slab.h>
22 #include <linux/i2c.h>
23 #include <linux/device.h>
25 #include <linux/module.h>
26 #include <linux/videodev2.h>
73 static const u8 adv7343_init_reg_val[] = {
142 for (i = 0; i < num_std; i++) {
143 if (std_info[i].
stdid & std)
149 "Invalid std or std is not supported: %llx\n",
150 (
unsigned long long)std);
173 fsc_ptr = (
unsigned char *)&std_info[i].
fsc_val;
175 for (i = 0; i < 4; i++, reg++, fsc_ptr++) {
176 err = adv7343_write(sd, reg, *fsc_ptr);
197 v4l2_err(sd,
"Error setting std, write failed\n");
202 static int adv7343_setoutput(
struct v4l2_subdev *sd,
u32 output_type)
210 "Invalid output type or output type not supported:%d\n",
216 val = state->
reg00 & 0x03;
258 v4l2_err(sd,
"Error setting output, write failed\n");
263 static int adv7343_log_status(
struct v4l2_subdev *sd)
267 v4l2_info(sd,
"Standard: %llx\n", (
unsigned long long)state->
std);
269 ((state->
output == 1) ?
"Component" :
"S-Video"));
291 static int adv7343_g_chip_ident(
struct v4l2_subdev *sd,
300 .s_ctrl = adv7343_s_ctrl,
304 .log_status = adv7343_log_status,
305 .g_chip_ident = adv7343_g_chip_ident,
320 if (state->
std == std)
323 err = adv7343_setstd(sd, std);
330 static int adv7343_s_routing(
struct v4l2_subdev *sd,
336 if (state->
output == output)
339 err = adv7343_setoutput(sd, output);
347 .s_std_output = adv7343_s_std_output,
348 .s_routing = adv7343_s_routing,
352 .core = &adv7343_core_ops,
353 .video = &adv7343_video_ops,
356 static int adv7343_initialize(
struct v4l2_subdev *sd)
362 for (i = 0; i <
ARRAY_SIZE(adv7343_init_reg_val); i += 2) {
364 err = adv7343_write(sd, adv7343_init_reg_val[i],
365 adv7343_init_reg_val[i+1]);
367 v4l2_err(sd,
"Error initializing\n");
373 err = adv7343_setoutput(sd, state->
output);
375 v4l2_err(sd,
"Error setting output during init\n");
379 err = adv7343_setstd(sd, state->
std);
381 v4l2_err(sd,
"Error setting std during init\n");
397 v4l_info(client,
"chip found @ 0x%x (%s)\n",
429 state->
sd.ctrl_handler = &state->
hdl;
430 if (state->
hdl.error) {
431 int err = state->
hdl.error;
439 err = adv7343_initialize(&state->
sd);
447 static int adv7343_remove(
struct i2c_client *client)
449 struct v4l2_subdev *sd = i2c_get_clientdata(client);
471 .probe = adv7343_probe,
472 .remove = adv7343_remove,
473 .id_table = adv7343_id,