Lines Matching full:sd

77 static int tvp514x_s_stream(struct v4l2_subdev *sd, int enable);
80 * @sd: Subdevice Slave handle
99 struct v4l2_subdev sd; member
262 static inline struct tvp514x_decoder *to_decoder(struct v4l2_subdev *sd) in to_decoder() argument
264 return container_of(sd, struct tvp514x_decoder, sd); in to_decoder()
269 return &container_of(ctrl->handler, struct tvp514x_decoder, hdl)->sd; in to_sd()
275 * @sd: ptr to v4l2_subdev struct
280 static int tvp514x_read_reg(struct v4l2_subdev *sd, u8 reg) in tvp514x_read_reg() argument
283 struct i2c_client *client = v4l2_get_subdevdata(sd); in tvp514x_read_reg()
290 v4l2_warn(sd, "Read: retry ... %d\n", retry); in tvp514x_read_reg()
302 * @sd: ptr to v4l2_subdev struct
305 static void dump_reg(struct v4l2_subdev *sd, u8 reg) in dump_reg() argument
309 val = tvp514x_read_reg(sd, reg); in dump_reg()
310 v4l2_info(sd, "Reg(0x%.2X): 0x%.2X\n", reg, val); in dump_reg()
315 * @sd: ptr to v4l2_subdev struct
322 static int tvp514x_write_reg(struct v4l2_subdev *sd, u8 reg, u8 val) in tvp514x_write_reg() argument
325 struct i2c_client *client = v4l2_get_subdevdata(sd); in tvp514x_write_reg()
332 v4l2_warn(sd, "Write: retry ... %d\n", retry); in tvp514x_write_reg()
344 * @sd: ptr to v4l2_subdev struct
354 static int tvp514x_write_regs(struct v4l2_subdev *sd, in tvp514x_write_regs() argument
369 err = tvp514x_write_reg(sd, next->reg, (u8) next->val); in tvp514x_write_regs()
371 v4l2_err(sd, "Write failed. Err[%d]\n", err); in tvp514x_write_regs()
380 * @sd: ptr to v4l2_subdev struct
385 static enum tvp514x_std tvp514x_query_current_std(struct v4l2_subdev *sd) in tvp514x_query_current_std() argument
389 std = tvp514x_read_reg(sd, REG_VIDEO_STD); in tvp514x_query_current_std()
392 std_status = tvp514x_read_reg(sd, REG_VIDEO_STD_STATUS); in tvp514x_query_current_std()
412 static void tvp514x_reg_dump(struct v4l2_subdev *sd) in tvp514x_reg_dump() argument
414 dump_reg(sd, REG_INPUT_SEL); in tvp514x_reg_dump()
415 dump_reg(sd, REG_AFE_GAIN_CTRL); in tvp514x_reg_dump()
416 dump_reg(sd, REG_VIDEO_STD); in tvp514x_reg_dump()
417 dump_reg(sd, REG_OPERATION_MODE); in tvp514x_reg_dump()
418 dump_reg(sd, REG_COLOR_KILLER); in tvp514x_reg_dump()
419 dump_reg(sd, REG_LUMA_CONTROL1); in tvp514x_reg_dump()
420 dump_reg(sd, REG_LUMA_CONTROL2); in tvp514x_reg_dump()
421 dump_reg(sd, REG_LUMA_CONTROL3); in tvp514x_reg_dump()
422 dump_reg(sd, REG_BRIGHTNESS); in tvp514x_reg_dump()
423 dump_reg(sd, REG_CONTRAST); in tvp514x_reg_dump()
424 dump_reg(sd, REG_SATURATION); in tvp514x_reg_dump()
425 dump_reg(sd, REG_HUE); in tvp514x_reg_dump()
426 dump_reg(sd, REG_CHROMA_CONTROL1); in tvp514x_reg_dump()
427 dump_reg(sd, REG_CHROMA_CONTROL2); in tvp514x_reg_dump()
428 dump_reg(sd, REG_COMP_PR_SATURATION); in tvp514x_reg_dump()
429 dump_reg(sd, REG_COMP_Y_CONTRAST); in tvp514x_reg_dump()
430 dump_reg(sd, REG_COMP_PB_SATURATION); in tvp514x_reg_dump()
431 dump_reg(sd, REG_COMP_Y_BRIGHTNESS); in tvp514x_reg_dump()
432 dump_reg(sd, REG_AVID_START_PIXEL_LSB); in tvp514x_reg_dump()
433 dump_reg(sd, REG_AVID_START_PIXEL_MSB); in tvp514x_reg_dump()
434 dump_reg(sd, REG_AVID_STOP_PIXEL_LSB); in tvp514x_reg_dump()
435 dump_reg(sd, REG_AVID_STOP_PIXEL_MSB); in tvp514x_reg_dump()
436 dump_reg(sd, REG_HSYNC_START_PIXEL_LSB); in tvp514x_reg_dump()
437 dump_reg(sd, REG_HSYNC_START_PIXEL_MSB); in tvp514x_reg_dump()
438 dump_reg(sd, REG_HSYNC_STOP_PIXEL_LSB); in tvp514x_reg_dump()
439 dump_reg(sd, REG_HSYNC_STOP_PIXEL_MSB); in tvp514x_reg_dump()
440 dump_reg(sd, REG_VSYNC_START_LINE_LSB); in tvp514x_reg_dump()
441 dump_reg(sd, REG_VSYNC_START_LINE_MSB); in tvp514x_reg_dump()
442 dump_reg(sd, REG_VSYNC_STOP_LINE_LSB); in tvp514x_reg_dump()
443 dump_reg(sd, REG_VSYNC_STOP_LINE_MSB); in tvp514x_reg_dump()
444 dump_reg(sd, REG_VBLK_START_LINE_LSB); in tvp514x_reg_dump()
445 dump_reg(sd, REG_VBLK_START_LINE_MSB); in tvp514x_reg_dump()
446 dump_reg(sd, REG_VBLK_STOP_LINE_LSB); in tvp514x_reg_dump()
447 dump_reg(sd, REG_VBLK_STOP_LINE_MSB); in tvp514x_reg_dump()
448 dump_reg(sd, REG_SYNC_CONTROL); in tvp514x_reg_dump()
449 dump_reg(sd, REG_OUTPUT_FORMATTER1); in tvp514x_reg_dump()
450 dump_reg(sd, REG_OUTPUT_FORMATTER2); in tvp514x_reg_dump()
451 dump_reg(sd, REG_OUTPUT_FORMATTER3); in tvp514x_reg_dump()
452 dump_reg(sd, REG_OUTPUT_FORMATTER4); in tvp514x_reg_dump()
453 dump_reg(sd, REG_OUTPUT_FORMATTER5); in tvp514x_reg_dump()
454 dump_reg(sd, REG_OUTPUT_FORMATTER6); in tvp514x_reg_dump()
455 dump_reg(sd, REG_CLEAR_LOST_LOCK); in tvp514x_reg_dump()
460 * @sd: ptr to v4l2_subdev struct
465 static int tvp514x_configure(struct v4l2_subdev *sd, in tvp514x_configure() argument
472 tvp514x_write_regs(sd, decoder->tvp514x_regs); in tvp514x_configure()
477 tvp514x_reg_dump(sd); in tvp514x_configure()
484 * @sd: pointer to standard V4L2 sub-device structure
493 static int tvp514x_detect(struct v4l2_subdev *sd, in tvp514x_detect() argument
497 struct i2c_client *client = v4l2_get_subdevdata(sd); in tvp514x_detect()
499 chip_id_msb = tvp514x_read_reg(sd, REG_CHIP_ID_MSB); in tvp514x_detect()
500 chip_id_lsb = tvp514x_read_reg(sd, REG_CHIP_ID_LSB); in tvp514x_detect()
501 rom_ver = tvp514x_read_reg(sd, REG_ROM_VERSION); in tvp514x_detect()
503 v4l2_dbg(1, debug, sd, in tvp514x_detect()
512 v4l2_err(sd, "chip id mismatch msb:0x%x lsb:0x%x\n", in tvp514x_detect()
519 v4l2_info(sd, "%s (Version - 0x%.2x) found at 0x%x (%s)\n", in tvp514x_detect()
527 * @sd: pointer to standard V4L2 sub-device structure
533 static int tvp514x_querystd(struct v4l2_subdev *sd, v4l2_std_id *std_id) in tvp514x_querystd() argument
535 struct tvp514x_decoder *decoder = to_decoder(sd); in tvp514x_querystd()
545 tvp514x_s_stream(sd, 1); in tvp514x_querystd()
550 current_std = tvp514x_query_current_std(sd); in tvp514x_querystd()
594 sync_lock_status = tvp514x_read_reg(sd, REG_STATUS1); in tvp514x_querystd()
602 v4l2_dbg(1, debug, sd, "Current STD: %s\n", in tvp514x_querystd()
609 * @sd: pointer to standard V4L2 sub-device structure
615 static int tvp514x_s_std(struct v4l2_subdev *sd, v4l2_std_id std_id) in tvp514x_s_std() argument
617 struct tvp514x_decoder *decoder = to_decoder(sd); in tvp514x_s_std()
627 err = tvp514x_write_reg(sd, REG_VIDEO_STD, in tvp514x_s_std()
636 v4l2_dbg(1, debug, sd, "Standard set to: %s\n", in tvp514x_s_std()
643 * @sd: pointer to standard V4L2 sub-device structure
652 static int tvp514x_s_routing(struct v4l2_subdev *sd, in tvp514x_s_routing() argument
655 struct tvp514x_decoder *decoder = to_decoder(sd); in tvp514x_s_routing()
668 err = tvp514x_write_reg(sd, REG_INPUT_SEL, input_sel); in tvp514x_s_routing()
672 output_sel |= tvp514x_read_reg(sd, in tvp514x_s_routing()
674 err = tvp514x_write_reg(sd, REG_OUTPUT_FORMATTER1, in tvp514x_s_routing()
684 v4l2_dbg(1, debug, sd, "Input set to: %d\n", input_sel); in tvp514x_s_routing()
698 struct v4l2_subdev *sd = to_sd(ctrl); in tvp514x_s_ctrl() local
699 struct tvp514x_decoder *decoder = to_decoder(sd); in tvp514x_s_ctrl()
706 err = tvp514x_write_reg(sd, REG_BRIGHTNESS, value); in tvp514x_s_ctrl()
711 err = tvp514x_write_reg(sd, REG_CONTRAST, value); in tvp514x_s_ctrl()
716 err = tvp514x_write_reg(sd, REG_SATURATION, value); in tvp514x_s_ctrl()
725 err = tvp514x_write_reg(sd, REG_HUE, value); in tvp514x_s_ctrl()
730 err = tvp514x_write_reg(sd, REG_AFE_GAIN_CTRL, value ? 0x0f : 0x0c); in tvp514x_s_ctrl()
736 v4l2_dbg(1, debug, sd, "Set Control: ID - %d - %d\n", in tvp514x_s_ctrl()
742 tvp514x_get_frame_interval(struct v4l2_subdev *sd, in tvp514x_get_frame_interval() argument
746 struct tvp514x_decoder *decoder = to_decoder(sd); in tvp514x_get_frame_interval()
766 tvp514x_set_frame_interval(struct v4l2_subdev *sd, in tvp514x_set_frame_interval() argument
770 struct tvp514x_decoder *decoder = to_decoder(sd); in tvp514x_set_frame_interval()
794 * @sd: pointer to standard V4L2 sub-device structure
799 static int tvp514x_s_stream(struct v4l2_subdev *sd, int enable) in tvp514x_s_stream() argument
802 struct tvp514x_decoder *decoder = to_decoder(sd); in tvp514x_s_stream()
811 err = tvp514x_write_reg(sd, REG_OPERATION_MODE, 0x01); in tvp514x_s_stream()
813 v4l2_err(sd, "Unable to turn off decoder\n"); in tvp514x_s_stream()
822 err = tvp514x_write_regs(sd, decoder->int_seq); in tvp514x_s_stream()
824 v4l2_err(sd, "Unable to turn on decoder\n"); in tvp514x_s_stream()
828 err = tvp514x_detect(sd, decoder); in tvp514x_s_stream()
830 v4l2_err(sd, "Unable to detect decoder\n"); in tvp514x_s_stream()
833 err = tvp514x_configure(sd, decoder); in tvp514x_s_stream()
835 v4l2_err(sd, "Unable to configure decoder\n"); in tvp514x_s_stream()
855 * @sd: pointer to standard V4L2 sub-device structure
861 static int tvp514x_enum_mbus_code(struct v4l2_subdev *sd, in tvp514x_enum_mbus_code() argument
882 * @sd: pointer to standard V4L2 sub-device structure
888 static int tvp514x_get_pad_format(struct v4l2_subdev *sd, in tvp514x_get_pad_format() argument
892 struct tvp514x_decoder *decoder = to_decoder(sd); in tvp514x_get_pad_format()
914 * @sd: pointer to standard V4L2 sub-device structure
920 static int tvp514x_set_pad_format(struct v4l2_subdev *sd, in tvp514x_set_pad_format() argument
924 struct tvp514x_decoder *decoder = to_decoder(sd); in tvp514x_set_pad_format()
1029 struct v4l2_subdev *sd; in tvp514x_probe() local
1071 sd = &decoder->sd; in tvp514x_probe()
1072 v4l2_i2c_subdev_init(sd, client, &tvp514x_ops); in tvp514x_probe()
1076 decoder->sd.flags |= V4L2_SUBDEV_FL_HAS_DEVNODE; in tvp514x_probe()
1077 decoder->sd.entity.function = MEDIA_ENT_F_ATV_DECODER; in tvp514x_probe()
1079 ret = media_entity_pads_init(&decoder->sd.entity, 1, &decoder->pad); in tvp514x_probe()
1081 v4l2_err(sd, "%s decoder driver failed to register !!\n", in tvp514x_probe()
1082 sd->name); in tvp514x_probe()
1097 sd->ctrl_handler = &decoder->hdl; in tvp514x_probe()
1104 ret = v4l2_async_register_subdev(&decoder->sd); in tvp514x_probe()
1106 v4l2_info(sd, "%s decoder driver registered !!\n", sd->name); in tvp514x_probe()
1111 media_entity_cleanup(&decoder->sd.entity); in tvp514x_probe()
1125 struct v4l2_subdev *sd = i2c_get_clientdata(client); in tvp514x_remove() local
1126 struct tvp514x_decoder *decoder = to_decoder(sd); in tvp514x_remove()
1128 v4l2_async_unregister_subdev(&decoder->sd); in tvp514x_remove()
1129 media_entity_cleanup(&decoder->sd.entity); in tvp514x_remove()