Lines Matching refs:ptr
41 static u8 zr36060_read(struct zr36060 *ptr, u16 reg)
44 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);
55 static void zr36060_write(struct zr36060 *ptr, u16 reg, u8 value)
57 struct zoran *zr = videocodec_to_zoran(ptr->codec);
62 if (ptr->codec->master_data->writereg)
63 ptr->codec->master_data->writereg(ptr->codec, reg, value);
65 zrdev_err(zr, "%s: invalid I/O setup, nothing written!\n", ptr->name);
75 static u8 zr36060_read_status(struct zr36060 *ptr)
77 ptr->status = zr36060_read(ptr, ZR060_CFSR);
79 zr36060_read(ptr, 0);
80 return ptr->status;
84 static u16 zr36060_read_scalefactor(struct zr36060 *ptr)
86 ptr->scalefact = (zr36060_read(ptr, ZR060_SF_HI) << 8) |
87 (zr36060_read(ptr, ZR060_SF_LO) & 0xFF);
90 zr36060_read(ptr, 0);
91 return ptr->scalefact;
95 static void zr36060_wait_end(struct zr36060 *ptr)
97 struct zoran *zr = videocodec_to_zoran(ptr->codec);
100 while (zr36060_read_status(ptr) & ZR060_CFSR_BUSY) {
105 ptr->name, ptr->status);
112 static int zr36060_basic_test(struct zr36060 *ptr)
114 struct zoran *zr = videocodec_to_zoran(ptr->codec);
116 if ((zr36060_read(ptr, ZR060_IDR_DEV) != 0x33) &&
117 (zr36060_read(ptr, ZR060_IDR_REV) != 0x01)) {
118 zrdev_err(zr, "%s: attach failed, can't connect to jpeg processor!\n", ptr->name);
122 zr36060_wait_end(ptr);
123 if (ptr->status & ZR060_CFSR_BUSY) {
124 zrdev_err(zr, "%s: attach failed, jpeg processor failed (end flag)!\n", ptr->name);
132 static int zr36060_pushit(struct zr36060 *ptr, u16 startreg, u16 len, const char *data)
134 struct zoran *zr = videocodec_to_zoran(ptr->codec);
137 zrdev_dbg(zr, "%s: write data block to 0x%04x (len=%d)\n", ptr->name,
140 zr36060_write(ptr, startreg++, data[i++]);
250 static int zr36060_set_sof(struct zr36060 *ptr)
252 struct zoran *zr = videocodec_to_zoran(ptr->codec);
256 zrdev_dbg(zr, "%s: write SOF (%dx%d, %d components)\n", ptr->name,
257 ptr->width, ptr->height, NO_OF_COMPONENTS);
263 sof_data[5] = (ptr->height) >> 8;
264 sof_data[6] = (ptr->height) & 0xff;
265 sof_data[7] = (ptr->width) >> 8;
266 sof_data[8] = (ptr->width) & 0xff;
270 sof_data[11 + (i * 3)] = (ptr->h_samp_ratio[i] << 4) |
271 (ptr->v_samp_ratio[i]); // sampling ratios
274 return zr36060_pushit(ptr, ZR060_SOF_IDX,
279 static int zr36060_set_sos(struct zr36060 *ptr)
281 struct zoran *zr = videocodec_to_zoran(ptr->codec);
285 zrdev_dbg(zr, "%s: write SOS\n", ptr->name);
299 return zr36060_pushit(ptr, ZR060_SOS_IDX,
305 static int zr36060_set_dri(struct zr36060 *ptr)
307 struct zoran *zr = videocodec_to_zoran(ptr->codec);
310 zrdev_dbg(zr, "%s: write DRI\n", ptr->name);
315 dri_data[4] = (ptr->dri) >> 8;
316 dri_data[5] = (ptr->dri) & 0xff;
317 return zr36060_pushit(ptr, ZR060_DRI_IDX, 6, dri_data);
323 static void zr36060_init(struct zr36060 *ptr)
327 struct zoran *zr = videocodec_to_zoran(ptr->codec);
329 if (ptr->mode == CODEC_DO_COMPRESSION) {
330 zrdev_dbg(zr, "%s: COMPRESSION SETUP\n", ptr->name);
332 zr36060_write(ptr, ZR060_LOAD, ZR060_LOAD_SYNC_RST);
335 zr36060_write(ptr, ZR060_CIR, ZR060_CIR_CODE_MSTR);
338 /*FIXME: What about ptr->bitrate_ctrl? */
339 zr36060_write(ptr, ZR060_CMR, ZR060_CMR_COMP | ZR060_CMR_PASS2 | ZR060_CMR_BRB);
342 zr36060_write(ptr, ZR060_MBZ, 0x00);
343 zr36060_write(ptr, ZR060_TCR_HI, 0x00);
344 zr36060_write(ptr, ZR060_TCR_LO, 0x00);
347 zr36060_write(ptr, ZR060_IMR, 0);
350 zr36060_write(ptr, ZR060_SF_HI, ptr->scalefact >> 8);
351 zr36060_write(ptr, ZR060_SF_LO, ptr->scalefact & 0xff);
353 zr36060_write(ptr, ZR060_AF_HI, 0xff);
354 zr36060_write(ptr, ZR060_AF_M, 0xff);
355 zr36060_write(ptr, ZR060_AF_LO, 0xff);
358 sum += zr36060_set_sof(ptr);
359 sum += zr36060_set_sos(ptr);
360 sum += zr36060_set_dri(ptr);
363 sum += zr36060_pushit(ptr, ZR060_DQT_IDX, sizeof(zr36060_dqt), zr36060_dqt);
364 sum += zr36060_pushit(ptr, ZR060_DHT_IDX, sizeof(zr36060_dht), zr36060_dht);
365 zr36060_write(ptr, ZR060_APP_IDX, 0xff);
366 zr36060_write(ptr, ZR060_APP_IDX + 1, 0xe0 + ptr->app.appn);
367 zr36060_write(ptr, ZR060_APP_IDX + 2, 0x00);
368 zr36060_write(ptr, ZR060_APP_IDX + 3, ptr->app.len + 2);
369 sum += zr36060_pushit(ptr, ZR060_APP_IDX + 4, 60, ptr->app.data) + 4;
370 zr36060_write(ptr, ZR060_COM_IDX, 0xff);
371 zr36060_write(ptr, ZR060_COM_IDX + 1, 0xfe);
372 zr36060_write(ptr, ZR060_COM_IDX + 2, 0x00);
373 zr36060_write(ptr, ZR060_COM_IDX + 3, ptr->com.len + 2);
374 sum += zr36060_pushit(ptr, ZR060_COM_IDX + 4, 60, ptr->com.data) + 4;
379 sum = ptr->real_code_vol - sum;
385 ptr->name, sum, ptr->real_code_vol, bitcnt, tmp);
386 zr36060_write(ptr, ZR060_TCV_NET_HI, tmp >> 8);
387 zr36060_write(ptr, ZR060_TCV_NET_MH, tmp & 0xff);
389 zr36060_write(ptr, ZR060_TCV_NET_ML, tmp >> 8);
390 zr36060_write(ptr, ZR060_TCV_NET_LO, tmp & 0xff);
397 ptr->name, bitcnt, tmp);
398 zr36060_write(ptr, ZR060_TCV_DATA_HI, tmp >> 8);
399 zr36060_write(ptr, ZR060_TCV_DATA_MH, tmp & 0xff);
401 zr36060_write(ptr, ZR060_TCV_DATA_ML, tmp >> 8);
402 zr36060_write(ptr, ZR060_TCV_DATA_LO, tmp & 0xff);
405 zr36060_write(ptr, ZR060_MER,
407 ((ptr->com.len > 0) ? ZR060_MER_COM : 0) |
408 ((ptr->app.len > 0) ? ZR060_MER_APP : 0));
412 zr36060_write(ptr, ZR060_VCR, ZR060_VCR_RANGE);
415 zrdev_dbg(zr, "%s: EXPANSION SETUP\n", ptr->name);
417 zr36060_write(ptr, ZR060_LOAD, ZR060_LOAD_SYNC_RST);
420 zr36060_write(ptr, ZR060_CIR, ZR060_CIR_CODE_MSTR);
423 zr36060_write(ptr, ZR060_CMR, 0);
426 zr36060_write(ptr, ZR060_MBZ, 0x00);
427 zr36060_write(ptr, ZR060_TCR_HI, 0x00);
428 zr36060_write(ptr, ZR060_TCR_LO, 0x00);
431 zr36060_write(ptr, ZR060_IMR, 0);
434 zr36060_write(ptr, ZR060_MER, 0);
437 zr36060_pushit(ptr, ZR060_DHT_IDX, sizeof(zr36060_dht), zr36060_dht);
440 //zr36060_write(ptr, ZR060_VCR, ZR060_VCR_FI_EXT);
442 zr36060_write(ptr, ZR060_VCR, ZR060_VCR_RANGE);
446 zr36060_write(ptr, ZR060_LOAD, ZR060_LOAD_SYNC_RST | ZR060_LOAD_LOAD);
447 zr36060_wait_end(ptr);
449 ptr->name, ptr->status);
451 if (ptr->status & ZR060_CFSR_BUSY) {
452 zrdev_err(zr, "%s: init aborted!\n", ptr->name);
468 struct zr36060 *ptr = (struct zr36060 *)codec->data;
471 zrdev_dbg(zr, "%s: set_mode %d call\n", ptr->name, mode);
476 ptr->mode = mode;
477 zr36060_init(ptr);
486 struct zr36060 *ptr = (struct zr36060 *)codec->data;
491 zrdev_dbg(zr, "%s: set_video (%u,%u)/%ux%u (%%%d) call\n", ptr->name,
498 ptr->width = cap->width / (cap->decimation & 0xff);
499 ptr->height = cap->height / (cap->decimation >> 8);
501 zr36060_write(ptr, ZR060_LOAD, ZR060_LOAD_SYNC_RST);
516 zr36060_write(ptr, ZR060_VPR, reg);
542 zr36060_write(ptr, ZR060_SR, reg);
544 zr36060_write(ptr, ZR060_BCR_Y, 0x00);
545 zr36060_write(ptr, ZR060_BCR_U, 0x80);
546 zr36060_write(ptr, ZR060_BCR_V, 0x80);
551 zr36060_write(ptr, ZR060_SGR_VTOTAL_HI, (reg >> 8) & 0xff);
552 zr36060_write(ptr, ZR060_SGR_VTOTAL_LO, (reg >> 0) & 0xff);
555 zr36060_write(ptr, ZR060_SGR_HTOTAL_HI, (reg >> 8) & 0xff);
556 zr36060_write(ptr, ZR060_SGR_HTOTAL_LO, (reg >> 0) & 0xff);
559 zr36060_write(ptr, ZR060_SGR_VSYNC, reg);
562 zr36060_write(ptr, ZR060_SGR_HSYNC, reg);
565 zr36060_write(ptr, ZR060_SGR_BVSTART, reg);
568 zr36060_write(ptr, ZR060_SGR_BVEND_HI, (reg >> 8) & 0xff);
569 zr36060_write(ptr, ZR060_SGR_BVEND_LO, (reg >> 0) & 0xff);
572 zr36060_write(ptr, ZR060_SGR_BHSTART, reg);
575 zr36060_write(ptr, ZR060_SGR_BHEND_HI, (reg >> 8) & 0xff);
576 zr36060_write(ptr, ZR060_SGR_BHEND_LO, (reg >> 0) & 0xff);
580 zr36060_write(ptr, ZR060_AAR_VSTART_HI, (reg >> 8) & 0xff);
581 zr36060_write(ptr, ZR060_AAR_VSTART_LO, (reg >> 0) & 0xff);
584 zr36060_write(ptr, ZR060_AAR_VEND_HI, (reg >> 8) & 0xff);
585 zr36060_write(ptr, ZR060_AAR_VEND_LO, (reg >> 0) & 0xff);
588 zr36060_write(ptr, ZR060_AAR_HSTART_HI, (reg >> 8) & 0xff);
589 zr36060_write(ptr, ZR060_AAR_HSTART_LO, (reg >> 0) & 0xff);
592 zr36060_write(ptr, ZR060_AAR_HEND_HI, (reg >> 8) & 0xff);
593 zr36060_write(ptr, ZR060_AAR_HEND_LO, (reg >> 0) & 0xff);
597 zr36060_write(ptr, ZR060_SWR_VSTART_HI, (reg >> 8) & 0xff);
598 zr36060_write(ptr, ZR060_SWR_VSTART_LO, (reg >> 0) & 0xff);
601 zr36060_write(ptr, ZR060_SWR_VEND_HI, (reg >> 8) & 0xff);
602 zr36060_write(ptr, ZR060_SWR_VEND_LO, (reg >> 0) & 0xff);
605 zr36060_write(ptr, ZR060_SWR_HSTART_HI, (reg >> 8) & 0xff);
606 zr36060_write(ptr, ZR060_SWR_HSTART_LO, (reg >> 0) & 0xff);
609 zr36060_write(ptr, ZR060_SWR_HEND_HI, (reg >> 8) & 0xff);
610 zr36060_write(ptr, ZR060_SWR_HEND_LO, (reg >> 0) & 0xff);
612 size = ptr->width * ptr->height;
626 if (size > ptr->total_code_vol * 7)
627 size = ptr->total_code_vol * 7;
629 ptr->real_code_vol = size >> 3; /* in bytes */
635 reg = ptr->max_block_vol;
636 zr36060_write(ptr, ZR060_MBCVR, reg);
644 struct zr36060 *ptr = (struct zr36060 *)codec->data;
648 zrdev_dbg(zr, "%s: control %d call with %d byte\n", ptr->name, type,
655 zr36060_read_status(ptr);
656 *ival = ptr->status;
685 *ival = ptr->total_code_vol;
691 ptr->total_code_vol = *ival;
692 ptr->real_code_vol = (ptr->total_code_vol * 6) >> 3;
698 *ival = zr36060_read_scalefactor(ptr);
704 ptr->scalefact = *ival;
713 *app = ptr->app;
723 ptr->app = *app;
733 *com = ptr->com;
743 ptr->com = *com;
761 struct zr36060 *ptr = codec->data;
764 if (ptr) {
767 zrdev_dbg(zr, "%s: finished codec #%d\n", ptr->name, ptr->num);
768 kfree(ptr);
787 struct zr36060 *ptr;
799 ptr = kzalloc(sizeof(*ptr), GFP_KERNEL);
800 codec->data = ptr;
801 if (!ptr)
804 snprintf(ptr->name, sizeof(ptr->name), "zr36060[%d]", zr36060_codecs);
805 ptr->num = zr36060_codecs++;
806 ptr->codec = codec;
809 res = zr36060_basic_test(ptr);
815 memcpy(ptr->h_samp_ratio, zr36060_decimation_h, 8);
816 memcpy(ptr->v_samp_ratio, zr36060_decimation_v, 8);
818 ptr->bitrate_ctrl = 0; /* 0 or 1 - fixed file size flag (what is the difference?) */
819 ptr->mode = CODEC_DO_COMPRESSION;
820 ptr->width = 384;
821 ptr->height = 288;
822 ptr->total_code_vol = 16000; /* CHECKME */
823 ptr->real_code_vol = (ptr->total_code_vol * 6) >> 3;
824 ptr->max_block_vol = 240; /* CHECKME, was 120 is 240 */
825 ptr->scalefact = 0x100;
826 ptr->dri = 1; /* CHECKME, was 8 is 1 */
829 ptr->com.len = 0;
830 ptr->app.appn = 0;
831 ptr->app.len = 0;
833 zr36060_init(ptr);
835 zrdev_info(zr, "%s: codec attached and running\n", ptr->name);