Lines Matching +full:jpeg +full:- +full:codec
1 // SPDX-License-Identifier: GPL-2.0-or-later
15 /* codec io API */
28 * Local hardware I/O functions: read/write via codec layer
36 struct zoran *zr = videocodec_to_zoran(ptr->codec); in zr36016_read()
39 if (ptr->codec->master_data->readreg) in zr36016_read()
40 value = (ptr->codec->master_data->readreg(ptr->codec, reg)) & 0xFF; in zr36016_read()
42 zrdev_err(zr, "%s: invalid I/O setup, nothing read!\n", ptr->name); in zr36016_read()
44 zrdev_dbg(zr, "%s: reading from 0x%04x: %02x\n", ptr->name, reg, value); in zr36016_read()
51 struct zoran *zr = videocodec_to_zoran(ptr->codec); in zr36016_write()
53 zrdev_dbg(zr, "%s: writing 0x%02x to 0x%04x\n", ptr->name, value, reg); in zr36016_write()
56 if (ptr->codec->master_data->writereg) in zr36016_write()
57 ptr->codec->master_data->writereg(ptr->codec, reg, value); in zr36016_write()
59 zrdev_err(zr, "%s: invalid I/O setup, nothing written!\n", ptr->name); in zr36016_write()
65 * the 016 supports auto-addr-increment, but
71 struct zoran *zr = videocodec_to_zoran(ptr->codec); in zr36016_readi()
74 if ((ptr->codec->master_data->writereg) && (ptr->codec->master_data->readreg)) { in zr36016_readi()
75 ptr->codec->master_data->writereg(ptr->codec, ZR016_IADDR, reg & 0x0F); in zr36016_readi()
76 value = (ptr->codec->master_data->readreg(ptr->codec, ZR016_IDATA)) & 0xFF; in zr36016_readi()
78 zrdev_err(zr, "%s: invalid I/O setup, nothing read (i)!\n", ptr->name); in zr36016_readi()
82 ptr->name, reg, value); in zr36016_readi()
88 struct zoran *zr = videocodec_to_zoran(ptr->codec); in zr36016_writei()
90 zrdev_dbg(zr, "%s: writing indirect 0x%02x to 0x%04x\n", ptr->name, in zr36016_writei()
94 if (ptr->codec->master_data->writereg) { in zr36016_writei()
95 ptr->codec->master_data->writereg(ptr->codec, ZR016_IADDR, reg & 0x0F); in zr36016_writei()
96 ptr->codec->master_data->writereg(ptr->codec, ZR016_IDATA, value & 0x0FF); in zr36016_writei()
98 zrdev_err(zr, "%s: invalid I/O setup, nothing written (i)!\n", ptr->name); in zr36016_writei()
107 ptr->version = zr36016_read(ptr, 0) >> 4; in zr36016_read_version()
108 return ptr->version; in zr36016_read_version()
113 * to/from PAX-Lo register
118 struct zoran *zr = videocodec_to_zoran(ptr->codec); in zr36016_basic_test()
124 zrdev_dbg(zr, "%s: registers: ", ptr->name); in zr36016_basic_test()
133 zrdev_err(zr, "%s: attach failed, can't connect to vfe processor!\n", ptr->name); in zr36016_basic_test()
134 return -ENXIO; in zr36016_basic_test()
138 zrdev_err(zr, "%s: attach failed, can't connect to vfe processor!\n", ptr->name); in zr36016_basic_test()
139 return -ENXIO; in zr36016_basic_test()
141 // we allow version numbers from 0-3, should be enough, though in zr36016_basic_test()
143 if (ptr->version & 0x0c) { in zr36016_basic_test()
144 zrdev_err(zr, "%s: attach failed, suspicious version %d found...\n", ptr->name, in zr36016_basic_test()
145 ptr->version); in zr36016_basic_test()
146 return -ENXIO; in zr36016_basic_test()
162 (ptr->mode == CODEC_DO_COMPRESSION ? in zr36016_init()
167 (ptr->xdec ? (ZR016_HRFL | ZR016_HORZ) : 0) | in zr36016_init()
168 (ptr->ydec ? ZR016_VERT : 0) | ZR016_CNTI); in zr36016_init()
173 zr36016_writei(ptr, ZR016I_PAX_HI, ptr->width >> 8); in zr36016_init()
174 zr36016_writei(ptr, ZR016I_PAX_LO, ptr->width & 0xFF); in zr36016_init()
175 zr36016_writei(ptr, ZR016I_PAY_HI, ptr->height >> 8); in zr36016_init()
176 zr36016_writei(ptr, ZR016I_PAY_LO, ptr->height & 0xFF); in zr36016_init()
177 zr36016_writei(ptr, ZR016I_NAX_HI, ptr->xoff >> 8); in zr36016_init()
178 zr36016_writei(ptr, ZR016I_NAX_LO, ptr->xoff & 0xFF); in zr36016_init()
179 zr36016_writei(ptr, ZR016I_NAY_HI, ptr->yoff >> 8); in zr36016_init()
180 zr36016_writei(ptr, ZR016I_NAY_LO, ptr->yoff & 0xFF); in zr36016_init()
187 * CODEC API FUNCTIONS
193 * set compression/expansion mode and launches codec -
196 static int zr36016_set_mode(struct videocodec *codec, int mode) in zr36016_set_mode() argument
198 struct zr36016 *ptr = (struct zr36016 *)codec->data; in zr36016_set_mode()
199 struct zoran *zr = videocodec_to_zoran(codec); in zr36016_set_mode()
201 zrdev_dbg(zr, "%s: set_mode %d call\n", ptr->name, mode); in zr36016_set_mode()
204 return -EINVAL; in zr36016_set_mode()
206 ptr->mode = mode; in zr36016_set_mode()
213 static int zr36016_set_video(struct videocodec *codec, const struct tvnorm *norm, in zr36016_set_video() argument
216 struct zr36016 *ptr = (struct zr36016 *)codec->data; in zr36016_set_video()
217 struct zoran *zr = videocodec_to_zoran(codec); in zr36016_set_video()
219 zrdev_dbg(zr, "%s: set_video %d.%d, %d/%d-%dx%d (0x%x) call\n", in zr36016_set_video()
220 ptr->name, norm->h_start, norm->v_start, in zr36016_set_video()
221 cap->x, cap->y, cap->width, cap->height, in zr36016_set_video()
222 cap->decimation); in zr36016_set_video()
225 * if () return -EINVAL; in zr36016_set_video()
226 * trust the master driver that it knows what it does - so in zr36016_set_video()
229 ptr->width = cap->width; in zr36016_set_video()
230 ptr->height = cap->height; in zr36016_set_video()
239 ptr->xoff = (norm->h_start ? norm->h_start : 1) + cap->x; in zr36016_set_video()
242 * v_start too high will cause the codec to 'not work'. I in zr36016_set_video()
246 ptr->yoff = norm->v_start + cap->y; in zr36016_set_video()
248 ptr->xdec = ((cap->decimation & 0xff) == 1) ? 0 : 1; in zr36016_set_video()
249 ptr->ydec = (((cap->decimation >> 8) & 0xff) == 1) ? 0 : 1; in zr36016_set_video()
255 static int zr36016_control(struct videocodec *codec, int type, int size, void *data) in zr36016_control() argument
257 struct zr36016 *ptr = (struct zr36016 *)codec->data; in zr36016_control()
258 struct zoran *zr = videocodec_to_zoran(codec); in zr36016_control()
262 ptr->name, type, size); in zr36016_control()
265 case CODEC_G_STATUS: /* get last status - we don't know it ... */ in zr36016_control()
267 return -EFAULT; in zr36016_control()
273 return -EFAULT; in zr36016_control()
279 return -EFAULT; in zr36016_control()
281 return -EINVAL; in zr36016_control()
291 return -ENXIO; in zr36016_control()
294 return -EINVAL; in zr36016_control()
303 * Deinitializes Zoran's JPEG processor
306 static int zr36016_unset(struct videocodec *codec) in zr36016_unset() argument
308 struct zr36016 *ptr = codec->data; in zr36016_unset()
309 struct zoran *zr = videocodec_to_zoran(codec); in zr36016_unset()
312 /* do wee need some codec deinit here, too ???? */ in zr36016_unset()
314 zrdev_dbg(zr, "%s: finished codec #%d\n", ptr->name, ptr->num); in zr36016_unset()
316 codec->data = NULL; in zr36016_unset()
318 zr36016_codecs--; in zr36016_unset()
322 return -EFAULT; in zr36016_unset()
328 * Initializes Zoran's JPEG processor
334 static int zr36016_setup(struct videocodec *codec) in zr36016_setup() argument
337 struct zoran *zr = videocodec_to_zoran(codec); in zr36016_setup()
344 return -ENOSPC; in zr36016_setup()
348 codec->data = ptr; in zr36016_setup()
350 return -ENOMEM; in zr36016_setup()
352 snprintf(ptr->name, sizeof(ptr->name), "zr36016[%d]", zr36016_codecs); in zr36016_setup()
353 ptr->num = zr36016_codecs++; in zr36016_setup()
354 ptr->codec = codec; in zr36016_setup()
359 zr36016_unset(codec); in zr36016_setup()
363 ptr->mode = CODEC_DO_COMPRESSION; in zr36016_setup()
364 ptr->width = 768; in zr36016_setup()
365 ptr->height = 288; in zr36016_setup()
366 ptr->xdec = 1; in zr36016_setup()
367 ptr->ydec = 0; in zr36016_setup()
370 zrdev_dbg(zr, "%s: codec v%d attached and running\n", in zr36016_setup()
371 ptr->name, ptr->version); in zr36016_setup()
402 pr_debug("zr36016: something's wrong - %d codecs left somehow.\n", in zr36016_cleanup_module()