184
190
0x06, 0x1a, /* subc. phase */
187
static int adv7175_command(struct i2c_client *client, unsigned cmd, void *arg)
189
struct adv7175 *encoder = i2c_get_clientdata(client);
193
static int adv7175_init(struct v4l2_subdev *sd, u32 val)
195
/* This is just for testing!!! */
196
adv7175_write_block(sd, init_common, sizeof(init_common));
197
adv7175_write(sd, 0x07, TR0MODE | TR0RST);
198
adv7175_write(sd, 0x07, TR0MODE);
202
static int adv7175_s_std_output(struct v4l2_subdev *sd, v4l2_std_id std)
204
struct adv7175 *encoder = to_adv7175(sd);
206
if (std & V4L2_STD_NTSC) {
207
adv7175_write_block(sd, init_ntsc, sizeof(init_ntsc));
208
if (encoder->input == 0)
209
adv7175_write(sd, 0x0d, 0x4f); /* Enable genlock */
210
adv7175_write(sd, 0x07, TR0MODE | TR0RST);
211
adv7175_write(sd, 0x07, TR0MODE);
212
} else if (std & V4L2_STD_PAL) {
213
adv7175_write_block(sd, init_pal, sizeof(init_pal));
214
if (encoder->input == 0)
215
adv7175_write(sd, 0x0d, 0x4f); /* Enable genlock */
216
adv7175_write(sd, 0x07, TR0MODE | TR0RST);
217
adv7175_write(sd, 0x07, TR0MODE);
218
} else if (std & V4L2_STD_SECAM) {
219
/* This is an attempt to convert
220
* SECAM->PAL (typically it does not work
221
* due to genlock: when decoder is in SECAM
222
* and encoder in in PAL the subcarrier can
223
* not be syncronized with horizontal
225
adv7175_write_block(sd, init_pal, sizeof(init_pal));
226
if (encoder->input == 0)
227
adv7175_write(sd, 0x0d, 0x49); /* Disable genlock */
228
adv7175_write(sd, 0x07, TR0MODE | TR0RST);
229
adv7175_write(sd, 0x07, TR0MODE);
231
v4l2_dbg(1, debug, sd, "illegal norm: %llx\n",
232
(unsigned long long)std);
235
v4l2_dbg(1, debug, sd, "switched to %llx\n", (unsigned long long)std);
240
static int adv7175_s_routing(struct v4l2_subdev *sd,
241
u32 input, u32 output, u32 config)
243
struct adv7175 *encoder = to_adv7175(sd);
245
/* RJ: input = 0: input is from decoder
246
input = 1: input is from ZR36060
247
input = 2: color bar */
193
/* This is just for testing!!! */
194
adv7175_write_block(client, init_common,
195
sizeof(init_common));
196
adv7175_write(client, 0x07, TR0MODE | TR0RST);
197
adv7175_write(client, 0x07, TR0MODE);
200
case ENCODER_GET_CAPABILITIES:
202
struct video_encoder_capability *cap = arg;
204
cap->flags = VIDEO_ENCODER_PAL |
206
VIDEO_ENCODER_SECAM; /* well, hacky */
212
case ENCODER_SET_NORM:
214
int iarg = *(int *) arg;
217
case VIDEO_MODE_NTSC:
218
adv7175_write_block(client, init_ntsc,
220
if (encoder->input == 0)
221
adv7175_write(client, 0x0d, 0x4f); // Enable genlock
222
adv7175_write(client, 0x07, TR0MODE | TR0RST);
223
adv7175_write(client, 0x07, TR0MODE);
227
adv7175_write_block(client, init_pal,
229
if (encoder->input == 0)
230
adv7175_write(client, 0x0d, 0x4f); // Enable genlock
231
adv7175_write(client, 0x07, TR0MODE | TR0RST);
232
adv7175_write(client, 0x07, TR0MODE);
235
case VIDEO_MODE_SECAM: // WARNING! ADV7176 does not support SECAM.
236
/* This is an attempt to convert
237
* SECAM->PAL (typically it does not work
238
* due to genlock: when decoder is in SECAM
239
* and encoder in in PAL the subcarrier can
240
* not be syncronized with horizontal
242
adv7175_write_block(client, init_pal,
244
if (encoder->input == 0)
245
adv7175_write(client, 0x0d, 0x49); // Disable genlock
246
adv7175_write(client, 0x07, TR0MODE | TR0RST);
247
adv7175_write(client, 0x07, TR0MODE);
250
v4l_dbg(1, debug, client, "illegal norm: %d\n", iarg);
253
v4l_dbg(1, debug, client, "switched to %s\n", norms[iarg]);
254
encoder->norm = iarg;
258
case ENCODER_SET_INPUT:
260
int iarg = *(int *) arg;
262
/* RJ: *iarg = 0: input is from SAA7110
263
*iarg = 1: input is from ZR36060
264
*iarg = 2: color bar */
268
adv7175_write(client, 0x01, 0x00);
270
if (encoder->norm == VIDEO_MODE_NTSC)
271
set_subcarrier_freq(client, 1);
273
adv7175_write(client, 0x0c, TR1CAPT); /* TR1 */
274
if (encoder->norm == VIDEO_MODE_SECAM)
275
adv7175_write(client, 0x0d, 0x49); // Disable genlock
277
adv7175_write(client, 0x0d, 0x4f); // Enable genlock
278
adv7175_write(client, 0x07, TR0MODE | TR0RST);
279
adv7175_write(client, 0x07, TR0MODE);
284
adv7175_write(client, 0x01, 0x00);
286
if (encoder->norm == VIDEO_MODE_NTSC)
287
set_subcarrier_freq(client, 0);
289
adv7175_write(client, 0x0c, TR1PLAY); /* TR1 */
290
adv7175_write(client, 0x0d, 0x49);
291
adv7175_write(client, 0x07, TR0MODE | TR0RST);
292
adv7175_write(client, 0x07, TR0MODE);
297
adv7175_write(client, 0x01, 0x80);
299
if (encoder->norm == VIDEO_MODE_NTSC)
300
set_subcarrier_freq(client, 0);
302
adv7175_write(client, 0x0d, 0x49);
303
adv7175_write(client, 0x07, TR0MODE | TR0RST);
304
adv7175_write(client, 0x07, TR0MODE);
309
v4l_dbg(1, debug, client, "illegal input: %d\n", iarg);
312
v4l_dbg(1, debug, client, "switched to %s\n", inputs[iarg]);
313
encoder->input = iarg;
317
case ENCODER_SET_OUTPUT:
321
/* not much choice of outputs */
327
case ENCODER_ENABLE_OUTPUT:
331
encoder->enable = !!*iarg;
251
adv7175_write(sd, 0x01, 0x00);
253
if (encoder->norm & V4L2_STD_NTSC)
254
set_subcarrier_freq(sd, 1);
256
adv7175_write(sd, 0x0c, TR1CAPT); /* TR1 */
257
if (encoder->norm & V4L2_STD_SECAM)
258
adv7175_write(sd, 0x0d, 0x49); /* Disable genlock */
260
adv7175_write(sd, 0x0d, 0x4f); /* Enable genlock */
261
adv7175_write(sd, 0x07, TR0MODE | TR0RST);
262
adv7175_write(sd, 0x07, TR0MODE);
267
adv7175_write(sd, 0x01, 0x00);
269
if (encoder->norm & V4L2_STD_NTSC)
270
set_subcarrier_freq(sd, 0);
272
adv7175_write(sd, 0x0c, TR1PLAY); /* TR1 */
273
adv7175_write(sd, 0x0d, 0x49);
274
adv7175_write(sd, 0x07, TR0MODE | TR0RST);
275
adv7175_write(sd, 0x07, TR0MODE);
280
adv7175_write(sd, 0x01, 0x80);
282
if (encoder->norm & V4L2_STD_NTSC)
283
set_subcarrier_freq(sd, 0);
285
adv7175_write(sd, 0x0d, 0x49);
286
adv7175_write(sd, 0x07, TR0MODE | TR0RST);
287
adv7175_write(sd, 0x07, TR0MODE);
292
v4l2_dbg(1, debug, sd, "illegal input: %d\n", input);
295
v4l2_dbg(1, debug, sd, "switched to %s\n", inputs[input]);
296
encoder->input = input;
342
/* ----------------------------------------------------------------------- */
346
* concerning the addresses: i2c wants 7 bit (without the r/w bit), so '>>1'
348
static unsigned short normal_i2c[] = {
349
I2C_ADV7175 >> 1, (I2C_ADV7175 >> 1) + 1,
350
I2C_ADV7176 >> 1, (I2C_ADV7176 >> 1) + 1,
300
static int adv7175_g_chip_ident(struct v4l2_subdev *sd, struct v4l2_dbg_chip_ident *chip)
302
struct i2c_client *client = v4l2_get_subdevdata(sd);
304
return v4l2_chip_ident_i2c_client(client, chip, V4L2_IDENT_ADV7175, 0);
307
/* ----------------------------------------------------------------------- */
309
static const struct v4l2_subdev_core_ops adv7175_core_ops = {
310
.g_chip_ident = adv7175_g_chip_ident,
311
.init = adv7175_init,
314
static const struct v4l2_subdev_video_ops adv7175_video_ops = {
315
.s_std_output = adv7175_s_std_output,
316
.s_routing = adv7175_s_routing,
319
static const struct v4l2_subdev_ops adv7175_ops = {
320
.core = &adv7175_core_ops,
321
.video = &adv7175_video_ops,
324
/* ----------------------------------------------------------------------- */
356
326
static int adv7175_probe(struct i2c_client *client,
357
327
const struct i2c_device_id *id)
360
330
struct adv7175 *encoder;
331
struct v4l2_subdev *sd;
362
333
/* Check if the adapter supports the needed features */
363
334
if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_BYTE_DATA))