Lines Matching refs:ptr

41 static u8 zr36050_read(struct zr36050 *ptr, u16 reg)
43 struct zoran *zr = videocodec_to_zoran(ptr->codec);
47 if (ptr->codec->master_data->readreg)
48 value = (ptr->codec->master_data->readreg(ptr->codec, reg)) & 0xFF;
50 zrdev_err(zr, "%s: invalid I/O setup, nothing read!\n", ptr->name);
52 zrdev_dbg(zr, "%s: reading from 0x%04x: %02x\n", ptr->name, reg, value);
57 static void zr36050_write(struct zr36050 *ptr, u16 reg, u8 value)
59 struct zoran *zr = videocodec_to_zoran(ptr->codec);
61 zrdev_dbg(zr, "%s: writing 0x%02x to 0x%04x\n", ptr->name, value, reg);
64 if (ptr->codec->master_data->writereg)
65 ptr->codec->master_data->writereg(ptr->codec, reg, value);
68 ptr->name);
72 static u8 zr36050_read_status1(struct zr36050 *ptr)
74 ptr->status1 = zr36050_read(ptr, ZR050_STATUS_1);
76 zr36050_read(ptr, 0);
77 return ptr->status1;
81 static u16 zr36050_read_scalefactor(struct zr36050 *ptr)
83 ptr->scalefact = (zr36050_read(ptr, ZR050_SF_HI) << 8) |
84 (zr36050_read(ptr, ZR050_SF_LO) & 0xFF);
87 zr36050_read(ptr, 0);
88 return ptr->scalefact;
97 static void zr36050_wait_end(struct zr36050 *ptr)
99 struct zoran *zr = videocodec_to_zoran(ptr->codec);
102 while (!(zr36050_read_status1(ptr) & 0x4)) {
107 ptr->name, ptr->status1);
118 static int zr36050_basic_test(struct zr36050 *ptr)
120 struct zoran *zr = videocodec_to_zoran(ptr->codec);
122 zr36050_write(ptr, ZR050_SOF_IDX, 0x00);
123 zr36050_write(ptr, ZR050_SOF_IDX + 1, 0x00);
124 if ((zr36050_read(ptr, ZR050_SOF_IDX) |
125 zr36050_read(ptr, ZR050_SOF_IDX + 1)) != 0x0000) {
128 ptr->name);
131 zr36050_write(ptr, ZR050_SOF_IDX, 0xff);
132 zr36050_write(ptr, ZR050_SOF_IDX + 1, 0xc0);
133 if (((zr36050_read(ptr, ZR050_SOF_IDX) << 8) |
134 zr36050_read(ptr, ZR050_SOF_IDX + 1)) != 0xffc0) {
137 ptr->name);
141 zr36050_wait_end(ptr);
142 if ((ptr->status1 & 0x4) == 0) {
145 ptr->name);
154 static int zr36050_pushit(struct zr36050 *ptr, u16 startreg, u16 len, const char *data)
156 struct zoran *zr = videocodec_to_zoran(ptr->codec);
159 zrdev_dbg(zr, "%s: write data block to 0x%04x (len=%d)\n", ptr->name,
162 zr36050_write(ptr, startreg++, data[i++]);
282 static int zr36050_set_sof(struct zr36050 *ptr)
284 struct zoran *zr = videocodec_to_zoran(ptr->codec);
288 zrdev_dbg(zr, "%s: write SOF (%dx%d, %d components)\n", ptr->name,
289 ptr->width, ptr->height, NO_OF_COMPONENTS);
295 sof_data[5] = (ptr->height) >> 8;
296 sof_data[6] = (ptr->height) & 0xff;
297 sof_data[7] = (ptr->width) >> 8;
298 sof_data[8] = (ptr->width) & 0xff;
302 sof_data[11 + (i * 3)] = (ptr->h_samp_ratio[i] << 4) |
303 (ptr->v_samp_ratio[i]); // sampling ratios
306 return zr36050_pushit(ptr, ZR050_SOF_IDX,
317 static int zr36050_set_sos(struct zr36050 *ptr)
319 struct zoran *zr = videocodec_to_zoran(ptr->codec);
323 zrdev_dbg(zr, "%s: write SOS\n", ptr->name);
336 return zr36050_pushit(ptr, ZR050_SOS1_IDX,
345 static int zr36050_set_dri(struct zr36050 *ptr)
347 struct zoran *zr = videocodec_to_zoran(ptr->codec);
350 zrdev_dbg(zr, "%s: write DRI\n", ptr->name);
355 dri_data[4] = ptr->dri >> 8;
356 dri_data[5] = ptr->dri & 0xff;
357 return zr36050_pushit(ptr, ZR050_DRI_IDX, 6, dri_data);
368 static void zr36050_init(struct zr36050 *ptr)
372 struct zoran *zr = videocodec_to_zoran(ptr->codec);
374 if (ptr->mode == CODEC_DO_COMPRESSION) {
375 zrdev_dbg(zr, "%s: COMPRESSION SETUP\n", ptr->name);
378 zr36050_write(ptr, ZR050_HARDWARE, ZR050_HW_MSTR);
381 zr36050_write(ptr, ZR050_MODE,
383 zr36050_write(ptr, ZR050_OPTIONS, 0);
386 zr36050_write(ptr, ZR050_INT_REQ_0, 0);
387 zr36050_write(ptr, ZR050_INT_REQ_1, 3); // low 2 bits always 1
390 /*zr36050_write(ptr, ZR050_MBCV, ptr->max_block_vol);*/
391 zr36050_write(ptr, ZR050_SF_HI, ptr->scalefact >> 8);
392 zr36050_write(ptr, ZR050_SF_LO, ptr->scalefact & 0xff);
394 zr36050_write(ptr, ZR050_AF_HI, 0xff);
395 zr36050_write(ptr, ZR050_AF_M, 0xff);
396 zr36050_write(ptr, ZR050_AF_LO, 0xff);
399 sum += zr36050_set_sof(ptr);
400 sum += zr36050_set_sos(ptr);
401 sum += zr36050_set_dri(ptr);
407 zrdev_dbg(zr, "%s: write DQT, DHT, APP\n", ptr->name);
408 sum += zr36050_pushit(ptr, ZR050_DQT_IDX,
410 sum += zr36050_pushit(ptr, ZR050_DHT_IDX,
412 zr36050_write(ptr, ZR050_APP_IDX, 0xff);
413 zr36050_write(ptr, ZR050_APP_IDX + 1, 0xe0 + ptr->app.appn);
414 zr36050_write(ptr, ZR050_APP_IDX + 2, 0x00);
415 zr36050_write(ptr, ZR050_APP_IDX + 3, ptr->app.len + 2);
416 sum += zr36050_pushit(ptr, ZR050_APP_IDX + 4, 60,
417 ptr->app.data) + 4;
418 zr36050_write(ptr, ZR050_COM_IDX, 0xff);
419 zr36050_write(ptr, ZR050_COM_IDX + 1, 0xfe);
420 zr36050_write(ptr, ZR050_COM_IDX + 2, 0x00);
421 zr36050_write(ptr, ZR050_COM_IDX + 3, ptr->com.len + 2);
422 sum += zr36050_pushit(ptr, ZR050_COM_IDX + 4, 60,
423 ptr->com.data) + 4;
426 zr36050_write(ptr, ZR050_MARKERS_EN, ZR050_ME_DHTI);
428 zr36050_write(ptr, ZR050_GO, 1); // launch codec
429 zr36050_wait_end(ptr);
431 ptr->name, ptr->status1);
433 if ((ptr->status1 & 0x4) == 0) {
434 zrdev_err(zr, "%s: init aborted!\n", ptr->name);
441 sum = ptr->real_code_vol - sum;
447 ptr->name, sum, ptr->real_code_vol, bitcnt, tmp);
448 zr36050_write(ptr, ZR050_TCV_NET_HI, tmp >> 8);
449 zr36050_write(ptr, ZR050_TCV_NET_MH, tmp & 0xff);
451 zr36050_write(ptr, ZR050_TCV_NET_ML, tmp >> 8);
452 zr36050_write(ptr, ZR050_TCV_NET_LO, tmp & 0xff);
459 ptr->name, bitcnt, tmp);
460 zr36050_write(ptr, ZR050_TCV_DATA_HI, tmp >> 8);
461 zr36050_write(ptr, ZR050_TCV_DATA_MH, tmp & 0xff);
463 zr36050_write(ptr, ZR050_TCV_DATA_ML, tmp >> 8);
464 zr36050_write(ptr, ZR050_TCV_DATA_LO, tmp & 0xff);
467 zr36050_write(ptr, ZR050_MODE,
469 (ptr->bitrate_ctrl ? ZR050_MO_BRC : 0));
472 zr36050_write(ptr, ZR050_MARKERS_EN,
474 ((ptr->app.len > 0) ? ZR050_ME_APP : 0) |
475 ((ptr->com.len > 0) ? ZR050_ME_COM : 0));
477 zrdev_dbg(zr, "%s: EXPANSION SETUP\n", ptr->name);
480 zr36050_write(ptr, ZR050_HARDWARE,
484 zr36050_write(ptr, ZR050_MODE, ZR050_MO_TLM);
487 zr36050_write(ptr, ZR050_INT_REQ_0, 0);
488 zr36050_write(ptr, ZR050_INT_REQ_1, 3); // low 2 bits always 1
490 zrdev_dbg(zr, "%s: write DHT\n", ptr->name);
491 zr36050_pushit(ptr, ZR050_DHT_IDX, sizeof(zr36050_dht),
495 zr36050_write(ptr, ZR050_MARKERS_EN, ZR050_ME_DHTI);
497 zr36050_write(ptr, ZR050_GO, 1); // launch codec
498 zr36050_wait_end(ptr);
500 ptr->name, ptr->status1);
502 if ((ptr->status1 & 0x4) == 0) {
503 zrdev_err(zr, "%s: init aborted!\n", ptr->name);
508 zr36050_write(ptr, ZR050_MODE, 0);
509 zr36050_write(ptr, ZR050_MARKERS_EN, 0);
513 zr36050_read(ptr, 0);
528 struct zr36050 *ptr = (struct zr36050 *)codec->data;
531 zrdev_dbg(zr, "%s: set_mode %d call\n", ptr->name, mode);
536 ptr->mode = mode;
537 zr36050_init(ptr);
546 struct zr36050 *ptr = (struct zr36050 *)codec->data;
551 ptr->name, norm->h_start, norm->v_start,
558 ptr->width = cap->width / (cap->decimation & 0xff);
559 ptr->height = cap->height / ((cap->decimation >> 8) & 0xff);
562 size = ptr->width * ptr->height;
571 if (size > ptr->total_code_vol * 7)
572 size = ptr->total_code_vol * 7;
574 ptr->real_code_vol = size >> 3; /* in bytes */
580 zr36050_write(ptr, ZR050_MBCV, ptr->max_block_vol);
588 struct zr36050 *ptr = (struct zr36050 *)codec->data;
592 zrdev_dbg(zr, "%s: control %d call with %d byte\n", ptr->name, type,
599 zr36050_read_status1(ptr);
600 *ival = ptr->status1;
629 *ival = ptr->total_code_vol;
635 ptr->total_code_vol = *ival;
636 ptr->real_code_vol = (ptr->total_code_vol * 6) >> 3;
642 *ival = zr36050_read_scalefactor(ptr);
648 ptr->scalefact = *ival;
657 *app = ptr->app;
667 ptr->app = *app;
677 *com = ptr->com;
687 ptr->com = *com;
702 struct zr36050 *ptr = codec->data;
705 if (ptr) {
708 zrdev_dbg(zr, "%s: finished codec #%d\n", ptr->name,
709 ptr->num);
710 kfree(ptr);
731 struct zr36050 *ptr;
744 ptr = kzalloc(sizeof(*ptr), GFP_KERNEL);
745 codec->data = ptr;
746 if (!ptr)
749 snprintf(ptr->name, sizeof(ptr->name), "zr36050[%d]",
751 ptr->num = zr36050_codecs++;
752 ptr->codec = codec;
755 res = zr36050_basic_test(ptr);
761 memcpy(ptr->h_samp_ratio, zr36050_decimation_h, 8);
762 memcpy(ptr->v_samp_ratio, zr36050_decimation_v, 8);
765 ptr->bitrate_ctrl = 0;
766 ptr->mode = CODEC_DO_COMPRESSION;
767 ptr->width = 384;
768 ptr->height = 288;
769 ptr->total_code_vol = 16000;
770 ptr->max_block_vol = 240;
771 ptr->scalefact = 0x100;
772 ptr->dri = 1;
775 ptr->app.appn = 0;
776 ptr->app.len = 0;
777 ptr->com.len = 0;
779 zr36050_init(ptr);
782 ptr->name);