Lines Matching +full:init +full:- +full:delay
1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * bt819 - BT819A VideoStream Decoder (Rockwell Part)
12 * - moved over to linux>=2.4.x i2c protocol (9/9/2002)
21 #include <linux/delay.h>
25 #include <media/v4l2-device.h>
26 #include <media/v4l2-ctrls.h>
29 MODULE_DESCRIPTION("Brooktree-819 video decoder driver");
35 MODULE_PARM_DESC(debug, "Debug level (0-1)");
38 /* ----------------------------------------------------------------------- */
57 return &container_of(ctrl->handler, struct bt819, hdl)->sd; in to_sd()
71 {864 - 24, 20, 625 - 2, 1, 0x0504, 0x0000},
72 {858 - 24, 20, 525 - 2, 1, 0x00f8, 0x0000},
75 /* ----------------------------------------------------------------------- */
79 struct i2c_client *client = v4l2_get_subdevdata(&decoder->sd); in bt819_write()
81 decoder->reg[reg] = value; in bt819_write()
88 (decoder->reg[reg] & ~(1 << bit)) | (value ? (1 << bit) : 0)); in bt819_setbit()
93 struct i2c_client *client = v4l2_get_subdevdata(&decoder->sd); in bt819_write_block()
94 int ret = -1; in bt819_write_block()
99 if (i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) { in bt819_write_block()
109 decoder->reg[reg++] = data[1]; in bt819_write_block()
110 len -= 2; in bt819_write_block()
124 len -= 2; in bt819_write_block()
133 struct i2c_client *client = v4l2_get_subdevdata(&decoder->sd); in bt819_read()
140 static unsigned char init[] = { in bt819_init() local
145 0x04, 0x16, /* 0x04 Vertical Delay, lsb */ in bt819_init()
147 0x06, 0x80, /* 0x06 Horizontal Delay lsb */ in bt819_init()
169 0x18, 0x68, /* 0x18 AGC Delay */ in bt819_init()
170 0x19, 0x5d, /* 0x19 Burst Gate Delay */ in bt819_init()
175 struct timing *timing = &timing_data[(decoder->norm & V4L2_STD_525_60) ? 1 : 0]; in bt819_init()
177 init[0x03 * 2 - 1] = in bt819_init()
178 (((timing->vdelay >> 8) & 0x03) << 6) | in bt819_init()
179 (((timing->vactive >> 8) & 0x03) << 4) | in bt819_init()
180 (((timing->hdelay >> 8) & 0x03) << 2) | in bt819_init()
181 ((timing->hactive >> 8) & 0x03); in bt819_init()
182 init[0x04 * 2 - 1] = timing->vdelay & 0xff; in bt819_init()
183 init[0x05 * 2 - 1] = timing->vactive & 0xff; in bt819_init()
184 init[0x06 * 2 - 1] = timing->hdelay & 0xff; in bt819_init()
185 init[0x07 * 2 - 1] = timing->hactive & 0xff; in bt819_init()
186 init[0x08 * 2 - 1] = timing->hscale >> 8; in bt819_init()
187 init[0x09 * 2 - 1] = timing->hscale & 0xff; in bt819_init()
189 init[0x15 * 2 - 1] = (decoder->norm & V4L2_STD_625_50) ? 115 : 93; /* Chroma burst delay */ in bt819_init()
194 /* init */ in bt819_init()
195 return bt819_write_block(decoder, init, sizeof(init)); in bt819_init()
198 /* ----------------------------------------------------------------------- */
242 if (sd->v4l2_dev == NULL || sd->v4l2_dev->notify == NULL) in bt819_s_std()
266 return -EINVAL; in bt819_s_std()
269 (((timing->vdelay >> 8) & 0x03) << 6) | in bt819_s_std()
270 (((timing->vactive >> 8) & 0x03) << 4) | in bt819_s_std()
271 (((timing->hdelay >> 8) & 0x03) << 2) | in bt819_s_std()
272 ((timing->hactive >> 8) & 0x03)); in bt819_s_std()
273 bt819_write(decoder, 0x04, timing->vdelay & 0xff); in bt819_s_std()
274 bt819_write(decoder, 0x05, timing->vactive & 0xff); in bt819_s_std()
275 bt819_write(decoder, 0x06, timing->hdelay & 0xff); in bt819_s_std()
276 bt819_write(decoder, 0x07, timing->hactive & 0xff); in bt819_s_std()
277 bt819_write(decoder, 0x08, (timing->hscale >> 8) & 0xff); in bt819_s_std()
278 bt819_write(decoder, 0x09, timing->hscale & 0xff); in bt819_s_std()
279 decoder->norm = std; in bt819_s_std()
292 return -EINVAL; in bt819_s_routing()
294 if (sd->v4l2_dev == NULL || sd->v4l2_dev->notify == NULL) in bt819_s_routing()
297 if (decoder->input != input) { in bt819_s_routing()
299 decoder->input = input; in bt819_s_routing()
301 if (decoder->input == 0) { in bt819_s_routing()
319 if (decoder->enable != enable) { in bt819_s_stream()
320 decoder->enable = enable; in bt819_s_stream()
332 switch (ctrl->id) { in bt819_s_ctrl()
334 bt819_write(decoder, 0x0a, ctrl->val); in bt819_s_ctrl()
338 bt819_write(decoder, 0x0c, ctrl->val & 0xff); in bt819_s_ctrl()
339 bt819_setbit(decoder, 0x0b, 2, ((ctrl->val >> 8) & 0x01)); in bt819_s_ctrl()
343 bt819_write(decoder, 0x0d, (ctrl->val >> 7) & 0xff); in bt819_s_ctrl()
344 bt819_setbit(decoder, 0x0b, 1, ((ctrl->val >> 15) & 0x01)); in bt819_s_ctrl()
348 temp = (ctrl->val * 180) / 254; in bt819_s_ctrl()
354 bt819_write(decoder, 0x0f, ctrl->val); in bt819_s_ctrl()
358 return -EINVAL; in bt819_s_ctrl()
363 /* ----------------------------------------------------------------------- */
381 /* ----------------------------------------------------------------------- */
391 if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_BYTE_DATA)) in bt819_probe()
392 return -ENODEV; in bt819_probe()
394 decoder = devm_kzalloc(&client->dev, sizeof(*decoder), GFP_KERNEL); in bt819_probe()
396 return -ENOMEM; in bt819_probe()
397 sd = &decoder->sd; in bt819_probe()
414 return -ENODEV; in bt819_probe()
418 client->addr << 1, client->adapter->name); in bt819_probe()
420 decoder->norm = V4L2_STD_NTSC; in bt819_probe()
421 decoder->input = 0; in bt819_probe()
422 decoder->enable = 1; in bt819_probe()
426 v4l2_dbg(1, debug, sd, "init status %d\n", i); in bt819_probe()
428 v4l2_ctrl_handler_init(&decoder->hdl, 4); in bt819_probe()
429 v4l2_ctrl_new_std(&decoder->hdl, &bt819_ctrl_ops, in bt819_probe()
430 V4L2_CID_BRIGHTNESS, -128, 127, 1, 0); in bt819_probe()
431 v4l2_ctrl_new_std(&decoder->hdl, &bt819_ctrl_ops, in bt819_probe()
433 v4l2_ctrl_new_std(&decoder->hdl, &bt819_ctrl_ops, in bt819_probe()
435 v4l2_ctrl_new_std(&decoder->hdl, &bt819_ctrl_ops, in bt819_probe()
436 V4L2_CID_HUE, -128, 127, 1, 0); in bt819_probe()
437 sd->ctrl_handler = &decoder->hdl; in bt819_probe()
438 if (decoder->hdl.error) { in bt819_probe()
439 int err = decoder->hdl.error; in bt819_probe()
441 v4l2_ctrl_handler_free(&decoder->hdl); in bt819_probe()
444 v4l2_ctrl_handler_setup(&decoder->hdl); in bt819_probe()
454 v4l2_ctrl_handler_free(&decoder->hdl); in bt819_remove()
457 /* ----------------------------------------------------------------------- */