23 #include <linux/kernel.h>
25 #include <linux/ctype.h>
26 #include <linux/slab.h>
27 #include <linux/i2c.h>
28 #include <linux/device.h>
30 #include <linux/module.h>
31 #include <linux/videodev2.h>
78 static const u8 adv7393_init_reg_val[] = {
148 for (i = 0; i < num_std; i++) {
149 if (stdinfo[i].
stdid & std)
155 "Invalid std or std is not supported: %llx\n",
156 (
unsigned long long)std);
160 std_info = &stdinfo[
i];
183 err = adv7393_write(sd, reg, val);
205 v4l2_err(sd,
"Error setting std, write failed\n");
210 static int adv7393_setoutput(
struct v4l2_subdev *sd,
u32 output_type)
218 "Invalid output type or output type not supported:%d\n",
224 val = state->
reg00 & 0x03;
269 v4l2_err(sd,
"Error setting output, write failed\n");
274 static int adv7393_log_status(
struct v4l2_subdev *sd)
278 v4l2_info(sd,
"Standard: %llx\n", (
unsigned long long)state->
std);
280 ((state->
output == 1) ?
"Component" :
"S-Video"));
304 static int adv7393_g_chip_ident(
struct v4l2_subdev *sd,
313 .s_ctrl = adv7393_s_ctrl,
317 .log_status = adv7393_log_status,
318 .g_chip_ident = adv7393_g_chip_ident,
333 if (state->
std == std)
336 err = adv7393_setstd(sd, std);
343 static int adv7393_s_routing(
struct v4l2_subdev *sd,
349 if (state->
output == output)
352 err = adv7393_setoutput(sd, output);
360 .s_std_output = adv7393_s_std_output,
361 .s_routing = adv7393_s_routing,
365 .core = &adv7393_core_ops,
366 .video = &adv7393_video_ops,
369 static int adv7393_initialize(
struct v4l2_subdev *sd)
375 for (i = 0; i <
ARRAY_SIZE(adv7393_init_reg_val); i += 2) {
377 err = adv7393_write(sd, adv7393_init_reg_val[i],
378 adv7393_init_reg_val[i+1]);
380 v4l2_err(sd,
"Error initializing\n");
386 err = adv7393_setoutput(sd, state->
output);
388 v4l2_err(sd,
"Error setting output during init\n");
392 err = adv7393_setstd(sd, state->
std);
394 v4l2_err(sd,
"Error setting std during init\n");
410 v4l_info(client,
"chip found @ 0x%x (%s)\n",
442 state->
sd.ctrl_handler = &state->
hdl;
443 if (state->
hdl.error) {
444 int err = state->
hdl.error;
452 err = adv7393_initialize(&state->
sd);
460 static int adv7393_remove(
struct i2c_client *client)
462 struct v4l2_subdev *sd = i2c_get_clientdata(client);
483 .probe = adv7393_probe,
484 .remove = adv7393_remove,
485 .id_table = adv7393_id,