2 * av7110_av.c: audio and video MPEG decoder stuff
4 * Copyright (C) 1999-2002 Ralph Metzler
5 * & Marcus Metzler for convergence integrated media GmbH
7 * originally based on code by:
8 * Copyright (C) 1998,1999 Christian Theiss <mistert@rz.fh-augsburg.de>
10 * This program is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU General Public License
12 * as published by the Free Software Foundation; either version 2
13 * of the License, or (at your option) any later version.
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * To obtain the license, point your browser to
22 * http://www.gnu.org/copyleft/gpl.html
25 * the project's page is at https://linuxtv.org
28 #include <linux/types.h>
29 #include <linux/kernel.h>
30 #include <linux/string.h>
31 #include <linux/delay.h>
35 #include "av7110_hw.h"
36 #include "av7110_av.h"
37 #include "av7110_ipack.h"
39 /* MPEG-2 (ISO 13818 / H.222.0) stream types */
40 #define PROG_STREAM_MAP 0xBC
41 #define PRIVATE_STREAM1 0xBD
42 #define PADDING_STREAM 0xBE
43 #define PRIVATE_STREAM2 0xBF
44 #define AUDIO_STREAM_S 0xC0
45 #define AUDIO_STREAM_E 0xDF
46 #define VIDEO_STREAM_S 0xE0
47 #define VIDEO_STREAM_E 0xEF
48 #define ECM_STREAM 0xF0
49 #define EMM_STREAM 0xF1
50 #define DSM_CC_STREAM 0xF2
51 #define ISO13522_STREAM 0xF3
52 #define PROG_STREAM_DIR 0xFF
54 #define PTS_DTS_FLAGS 0xC0
60 #define TRANS_ERROR 0x80
61 #define PAY_START 0x40
62 #define TRANS_PRIO 0x20
63 #define PID_MASK_HI 0x1F
65 #define TRANS_SCRMBL1 0x80
66 #define TRANS_SCRMBL2 0x40
67 #define ADAPT_FIELD 0x20
69 #define COUNT_MASK 0x0F
72 #define DISCON_IND 0x80
73 #define RAND_ACC_IND 0x40
74 #define ES_PRI_IND 0x20
76 #define OPCR_FLAG 0x08
77 #define SPLICE_FLAG 0x04
78 #define TRANS_PRIV 0x02
79 #define ADAP_EXT_FLAG 0x01
81 // adaptation extension flags
83 #define PIECE_RATE 0x40
84 #define SEAM_SPLICE 0x20
87 static void p_to_t(u8
const *buf
, long int length
, u16 pid
,
88 u8
*counter
, struct dvb_demux_feed
*feed
);
89 static int write_ts_to_decoder(struct av7110
*av7110
, int type
, const u8
*buf
, size_t len
);
92 int av7110_record_cb(struct dvb_filter_pes2ts
*p2t
, u8
*buf
, size_t len
)
94 struct dvb_demux_feed
*dvbdmxfeed
= (struct dvb_demux_feed
*) p2t
->priv
;
96 if (!(dvbdmxfeed
->ts_type
& TS_PACKET
))
98 if (buf
[3] == 0xe0) // video PES do not have a length in TS
100 if (dvbdmxfeed
->ts_type
& TS_PAYLOAD_ONLY
)
101 return dvbdmxfeed
->cb
.ts(buf
, len
, NULL
, 0,
102 &dvbdmxfeed
->feed
.ts
, NULL
);
104 return dvb_filter_pes2ts(p2t
, buf
, len
, 1);
107 static int dvb_filter_pes2ts_cb(void *priv
, unsigned char *data
)
109 struct dvb_demux_feed
*dvbdmxfeed
= (struct dvb_demux_feed
*) priv
;
111 dvbdmxfeed
->cb
.ts(data
, 188, NULL
, 0,
112 &dvbdmxfeed
->feed
.ts
, NULL
);
116 int av7110_av_start_record(struct av7110
*av7110
, int av
,
117 struct dvb_demux_feed
*dvbdmxfeed
)
120 struct dvb_demux
*dvbdmx
= dvbdmxfeed
->demux
;
122 dprintk(2, "av7110:%p, , dvb_demux_feed:%p\n", av7110
, dvbdmxfeed
);
124 if (av7110
->playing
|| (av7110
->rec_mode
& av
))
126 av7110_fw_cmd(av7110
, COMTYPE_REC_PLAY
, __Stop
, 0);
127 dvbdmx
->recording
= 1;
128 av7110
->rec_mode
|= av
;
130 switch (av7110
->rec_mode
) {
132 dvb_filter_pes2ts_init(&av7110
->p2t
[0],
133 dvbdmx
->pesfilter
[0]->pid
,
134 dvb_filter_pes2ts_cb
,
135 (void *) dvbdmx
->pesfilter
[0]);
136 ret
= av7110_fw_cmd(av7110
, COMTYPE_REC_PLAY
, __Record
, 2, AudioPES
, 0);
140 dvb_filter_pes2ts_init(&av7110
->p2t
[1],
141 dvbdmx
->pesfilter
[1]->pid
,
142 dvb_filter_pes2ts_cb
,
143 (void *) dvbdmx
->pesfilter
[1]);
144 ret
= av7110_fw_cmd(av7110
, COMTYPE_REC_PLAY
, __Record
, 2, VideoPES
, 0);
148 dvb_filter_pes2ts_init(&av7110
->p2t
[0],
149 dvbdmx
->pesfilter
[0]->pid
,
150 dvb_filter_pes2ts_cb
,
151 (void *) dvbdmx
->pesfilter
[0]);
152 dvb_filter_pes2ts_init(&av7110
->p2t
[1],
153 dvbdmx
->pesfilter
[1]->pid
,
154 dvb_filter_pes2ts_cb
,
155 (void *) dvbdmx
->pesfilter
[1]);
156 ret
= av7110_fw_cmd(av7110
, COMTYPE_REC_PLAY
, __Record
, 2, AV_PES
, 0);
162 int av7110_av_start_play(struct av7110
*av7110
, int av
)
165 dprintk(2, "av7110:%p, \n", av7110
);
167 if (av7110
->rec_mode
)
169 if (av7110
->playing
& av
)
172 av7110_fw_cmd(av7110
, COMTYPE_REC_PLAY
, __Stop
, 0);
174 if (av7110
->playing
== RP_NONE
) {
175 av7110_ipack_reset(&av7110
->ipack
[0]);
176 av7110_ipack_reset(&av7110
->ipack
[1]);
179 av7110
->playing
|= av
;
180 switch (av7110
->playing
) {
182 ret
= av7110_fw_cmd(av7110
, COMTYPE_REC_PLAY
, __Play
, 2, AudioPES
, 0);
185 ret
= av7110_fw_cmd(av7110
, COMTYPE_REC_PLAY
, __Play
, 2, VideoPES
, 0);
190 ret
= av7110_fw_cmd(av7110
, COMTYPE_REC_PLAY
, __Play
, 2, AV_PES
, 0);
196 int av7110_av_stop(struct av7110
*av7110
, int av
)
199 dprintk(2, "av7110:%p, \n", av7110
);
201 if (!(av7110
->playing
& av
) && !(av7110
->rec_mode
& av
))
203 av7110_fw_cmd(av7110
, COMTYPE_REC_PLAY
, __Stop
, 0);
204 if (av7110
->playing
) {
205 av7110
->playing
&= ~av
;
206 switch (av7110
->playing
) {
208 ret
= av7110_fw_cmd(av7110
, COMTYPE_REC_PLAY
, __Play
, 2, AudioPES
, 0);
211 ret
= av7110_fw_cmd(av7110
, COMTYPE_REC_PLAY
, __Play
, 2, VideoPES
, 0);
214 ret
= av7110_set_vidmode(av7110
, av7110
->vidmode
);
218 av7110
->rec_mode
&= ~av
;
219 switch (av7110
->rec_mode
) {
221 ret
= av7110_fw_cmd(av7110
, COMTYPE_REC_PLAY
, __Record
, 2, AudioPES
, 0);
224 ret
= av7110_fw_cmd(av7110
, COMTYPE_REC_PLAY
, __Record
, 2, VideoPES
, 0);
234 int av7110_pes_play(void *dest
, struct dvb_ringbuffer
*buf
, int dlen
)
241 wake_up(&buf
->queue
);
245 len
= dvb_ringbuffer_avail(buf
);
247 wake_up(&buf
->queue
);
250 sync
= DVB_RINGBUFFER_PEEK(buf
, 0) << 24;
251 sync
|= DVB_RINGBUFFER_PEEK(buf
, 1) << 16;
252 sync
|= DVB_RINGBUFFER_PEEK(buf
, 2) << 8;
253 sync
|= DVB_RINGBUFFER_PEEK(buf
, 3);
255 if (((sync
&~ 0x0f) == 0x000001e0) ||
256 ((sync
&~ 0x1f) == 0x000001c0) ||
257 (sync
== 0x000001bd))
260 DVB_RINGBUFFER_SKIP(buf
, 1);
262 blen
= DVB_RINGBUFFER_PEEK(buf
, 4) << 8;
263 blen
|= DVB_RINGBUFFER_PEEK(buf
, 5);
265 if (len
< blen
|| blen
> dlen
) {
266 //printk("buffer empty - avail %d blen %u dlen %d\n", len, blen, dlen);
267 wake_up(&buf
->queue
);
271 dvb_ringbuffer_read(buf
, dest
, (size_t) blen
);
273 dprintk(2, "pread=0x%08lx, pwrite=0x%08lx\n",
274 (unsigned long) buf
->pread
, (unsigned long) buf
->pwrite
);
275 wake_up(&buf
->queue
);
280 int av7110_set_volume(struct av7110
*av7110
, unsigned int volleft
,
281 unsigned int volright
)
283 unsigned int vol
, val
, balance
= 0;
286 dprintk(2, "av7110:%p, \n", av7110
);
288 av7110
->mixer
.volume_left
= volleft
;
289 av7110
->mixer
.volume_right
= volright
;
291 switch (av7110
->adac_type
) {
293 volleft
= (volleft
* 256) / 1036;
294 volright
= (volright
* 256) / 1036;
299 if ((err
= SendDAC(av7110
, 3, 0x80 + volleft
)))
301 return SendDAC(av7110
, 4, volright
);
303 case DVB_ADAC_CRYSTAL
:
304 volleft
= 127 - volleft
/ 2;
305 volright
= 127 - volright
/ 2;
306 i2c_writereg(av7110
, 0x20, 0x03, volleft
);
307 i2c_writereg(av7110
, 0x20, 0x04, volright
);
310 case DVB_ADAC_MSP34x0
:
311 vol
= (volleft
> volright
) ? volleft
: volright
;
312 val
= (vol
* 0x73 / 255) << 8;
314 balance
= ((volright
- volleft
) * 127) / vol
;
315 msp_writereg(av7110
, MSP_WR_DSP
, 0x0001, balance
<< 8);
316 msp_writereg(av7110
, MSP_WR_DSP
, 0x0000, val
); /* loudspeaker */
317 msp_writereg(av7110
, MSP_WR_DSP
, 0x0006, val
); /* headphonesr */
320 case DVB_ADAC_MSP34x5
:
321 vol
= (volleft
> volright
) ? volleft
: volright
;
322 val
= (vol
* 0x73 / 255) << 8;
324 balance
= ((volright
- volleft
) * 127) / vol
;
325 msp_writereg(av7110
, MSP_WR_DSP
, 0x0001, balance
<< 8);
326 msp_writereg(av7110
, MSP_WR_DSP
, 0x0000, val
); /* loudspeaker */
333 int av7110_set_vidmode(struct av7110
*av7110
, enum av7110_video_mode mode
)
336 dprintk(2, "av7110:%p, \n", av7110
);
338 ret
= av7110_fw_cmd(av7110
, COMTYPE_ENCODER
, LoadVidCode
, 1, mode
);
340 if (!ret
&& !av7110
->playing
) {
341 ret
= ChangePIDs(av7110
, av7110
->pids
[DMX_PES_VIDEO
],
342 av7110
->pids
[DMX_PES_AUDIO
],
343 av7110
->pids
[DMX_PES_TELETEXT
],
344 0, av7110
->pids
[DMX_PES_PCR
]);
346 ret
= av7110_fw_cmd(av7110
, COMTYPE_PIDFILTER
, Scan
, 0);
352 static enum av7110_video_mode sw2mode
[16] = {
353 AV7110_VIDEO_MODE_PAL
, AV7110_VIDEO_MODE_NTSC
,
354 AV7110_VIDEO_MODE_NTSC
, AV7110_VIDEO_MODE_PAL
,
355 AV7110_VIDEO_MODE_NTSC
, AV7110_VIDEO_MODE_NTSC
,
356 AV7110_VIDEO_MODE_PAL
, AV7110_VIDEO_MODE_NTSC
,
357 AV7110_VIDEO_MODE_PAL
, AV7110_VIDEO_MODE_PAL
,
358 AV7110_VIDEO_MODE_PAL
, AV7110_VIDEO_MODE_PAL
,
359 AV7110_VIDEO_MODE_PAL
, AV7110_VIDEO_MODE_PAL
,
360 AV7110_VIDEO_MODE_PAL
, AV7110_VIDEO_MODE_PAL
,
363 static int get_video_format(struct av7110
*av7110
, u8
*buf
, int count
)
371 dprintk(2, "av7110:%p, \n", av7110
);
375 for (i
= 7; i
< count
- 10; i
++) {
377 if (p
[0] || p
[1] || p
[2] != 0x01 || p
[3] != 0xb3)
380 hsize
= ((p
[1] &0xF0) >> 4) | (p
[0] << 4);
381 vsize
= ((p
[1] &0x0F) << 8) | (p
[2]);
383 ret
= av7110_set_vidmode(av7110
, sw2mode
[sw
]);
385 dprintk(2, "playback %dx%d fr=%d\n", hsize
, vsize
, sw
);
394 /****************************************************************************
395 * I/O buffer management and control
396 ****************************************************************************/
398 static inline long aux_ring_buffer_write(struct dvb_ringbuffer
*rbuf
,
399 const u8
*buf
, unsigned long count
)
401 unsigned long todo
= count
;
405 if (dvb_ringbuffer_free(rbuf
) < 2048) {
406 if (wait_event_interruptible(rbuf
->queue
,
407 (dvb_ringbuffer_free(rbuf
) >= 2048)))
410 free
= dvb_ringbuffer_free(rbuf
);
413 dvb_ringbuffer_write(rbuf
, buf
, free
);
421 static void play_video_cb(u8
*buf
, int count
, void *priv
)
423 struct av7110
*av7110
= (struct av7110
*) priv
;
424 dprintk(2, "av7110:%p, \n", av7110
);
426 if ((buf
[3] & 0xe0) == 0xe0) {
427 get_video_format(av7110
, buf
, count
);
428 aux_ring_buffer_write(&av7110
->avout
, buf
, count
);
430 aux_ring_buffer_write(&av7110
->aout
, buf
, count
);
433 static void play_audio_cb(u8
*buf
, int count
, void *priv
)
435 struct av7110
*av7110
= (struct av7110
*) priv
;
436 dprintk(2, "av7110:%p, \n", av7110
);
438 aux_ring_buffer_write(&av7110
->aout
, buf
, count
);
442 #define FREE_COND_TS (dvb_ringbuffer_free(rb) >= 4096)
444 static ssize_t
ts_play(struct av7110
*av7110
, const char __user
*buf
,
445 unsigned long count
, int nonblock
, int type
)
447 struct dvb_ringbuffer
*rb
;
449 unsigned long todo
= count
;
451 dprintk(2, "%s: type %d cnt %lu\n", __func__
, type
, count
);
453 rb
= (type
) ? &av7110
->avout
: &av7110
->aout
;
454 kb
= av7110
->kbuf
[type
];
459 if (nonblock
&& !FREE_COND_TS
)
462 while (todo
>= TS_SIZE
) {
466 if (wait_event_interruptible(rb
->queue
, FREE_COND_TS
))
469 if (copy_from_user(kb
, buf
, TS_SIZE
))
471 write_ts_to_decoder(av7110
, type
, kb
, TS_SIZE
);
480 #define FREE_COND (dvb_ringbuffer_free(&av7110->avout) >= 20 * 1024 && \
481 dvb_ringbuffer_free(&av7110->aout) >= 20 * 1024)
483 static ssize_t
dvb_play(struct av7110
*av7110
, const char __user
*buf
,
484 unsigned long count
, int nonblock
, int type
)
486 unsigned long todo
= count
, n
;
487 dprintk(2, "av7110:%p, \n", av7110
);
489 if (!av7110
->kbuf
[type
])
492 if (nonblock
&& !FREE_COND
)
499 if (wait_event_interruptible(av7110
->avout
.queue
,
506 if (copy_from_user(av7110
->kbuf
[type
], buf
, n
))
508 av7110_ipack_instant_repack(av7110
->kbuf
[type
], n
,
509 &av7110
->ipack
[type
]);
516 static ssize_t
dvb_play_kernel(struct av7110
*av7110
, const u8
*buf
,
517 unsigned long count
, int nonblock
, int type
)
519 unsigned long todo
= count
, n
;
520 dprintk(2, "av7110:%p, \n", av7110
);
522 if (!av7110
->kbuf
[type
])
525 if (nonblock
&& !FREE_COND
)
532 if (wait_event_interruptible(av7110
->avout
.queue
,
539 av7110_ipack_instant_repack(buf
, n
, &av7110
->ipack
[type
]);
546 static ssize_t
dvb_aplay(struct av7110
*av7110
, const char __user
*buf
,
547 unsigned long count
, int nonblock
, int type
)
549 unsigned long todo
= count
, n
;
550 dprintk(2, "av7110:%p, \n", av7110
);
552 if (!av7110
->kbuf
[type
])
554 if (nonblock
&& dvb_ringbuffer_free(&av7110
->aout
) < 20 * 1024)
558 if (dvb_ringbuffer_free(&av7110
->aout
) < 20 * 1024) {
561 if (wait_event_interruptible(av7110
->aout
.queue
,
562 (dvb_ringbuffer_free(&av7110
->aout
) >= 20 * 1024)))
568 if (copy_from_user(av7110
->kbuf
[type
], buf
, n
))
570 av7110_ipack_instant_repack(av7110
->kbuf
[type
], n
,
571 &av7110
->ipack
[type
]);
578 void av7110_p2t_init(struct av7110_p2t
*p
, struct dvb_demux_feed
*feed
)
580 memset(p
->pes
, 0, TS_SIZE
);
588 static void clear_p2t(struct av7110_p2t
*p
)
590 memset(p
->pes
, 0, TS_SIZE
);
597 static int find_pes_header(u8
const *buf
, long int length
, int *frags
)
604 while (c
< length
- 3 && !found
) {
605 if (buf
[c
] == 0x00 && buf
[c
+ 1] == 0x00 &&
606 buf
[c
+ 2] == 0x01) {
607 switch ( buf
[c
+ 3] ) {
608 case PROG_STREAM_MAP
:
609 case PRIVATE_STREAM2
:
610 case PROG_STREAM_DIR
:
613 case PADDING_STREAM
:
615 case ISO13522_STREAM
:
616 case PRIVATE_STREAM1
:
617 case AUDIO_STREAM_S
... AUDIO_STREAM_E
:
618 case VIDEO_STREAM_S
... VIDEO_STREAM_E
:
629 if (c
== length
- 3 && !found
) {
630 if (buf
[length
- 1] == 0x00)
632 if (buf
[length
- 2] == 0x00 &&
633 buf
[length
- 1] == 0x00)
635 if (buf
[length
- 3] == 0x00 &&
636 buf
[length
- 2] == 0x00 &&
637 buf
[length
- 1] == 0x01)
645 void av7110_p2t_write(u8
const *buf
, long int length
, u16 pid
, struct av7110_p2t
*p
)
656 if (buf
[c
] == 0x00 && buf
[c
+ 1] == 0x01) {
662 if (buf
[c
] == 0x01) {
672 case PROG_STREAM_MAP
:
673 case PRIVATE_STREAM2
:
674 case PROG_STREAM_DIR
:
677 case PADDING_STREAM
:
679 case ISO13522_STREAM
:
680 case PRIVATE_STREAM1
:
681 case AUDIO_STREAM_S
... AUDIO_STREAM_E
:
682 case VIDEO_STREAM_S
... VIDEO_STREAM_E
:
688 memcpy(p
->pes
+ p
->pos
, buf
+ c
, (TS_SIZE
- 4) - p
->pos
);
689 c
+= (TS_SIZE
- 4) - p
->pos
;
690 p_to_t(p
->pes
, (TS_SIZE
- 4), pid
, &p
->counter
, p
->feed
);
703 c2
= find_pes_header(buf
+ c
, length
- c
, &p
->frags
);
704 if (c2
>= 0 && c2
< (TS_SIZE
- 4) - p
->pos
)
707 l
= (TS_SIZE
- 4) - p
->pos
;
708 memcpy(p
->pes
+ p
->pos
, buf
, l
);
711 p_to_t(p
->pes
, p
->pos
, pid
, &p
->counter
, p
->feed
);
717 c2
= find_pes_header(buf
+ c
+ add
, length
- c
- add
, &p
->frags
);
721 p_to_t(buf
+ c
, c2
- c
, pid
, &p
->counter
, p
->feed
);
729 rest
= l
% (TS_SIZE
- 4);
731 p_to_t(buf
+ c
, l
, pid
, &p
->counter
, p
->feed
);
732 memcpy(p
->pes
, buf
+ c
+ l
, rest
);
740 static int write_ts_header2(u16 pid
, u8
*counter
, int pes_start
, u8
*buf
, u8 length
)
745 u8 tshead
[4] = { 0x47, 0x00, 0x00, 0x10 };
747 fill
= (TS_SIZE
- 4) - length
;
752 tshead
[1] |= (u8
)((pid
& 0x1F00) >> 8);
753 tshead
[2] |= (u8
)(pid
& 0x00FF);
754 tshead
[3] |= ((*counter
)++ & 0x0F);
755 memcpy(buf
, tshead
, 4);
765 for (i
= 6; i
< fill
+ 4; i
++) {
775 static void p_to_t(u8
const *buf
, long int length
, u16 pid
, u8
*counter
,
776 struct dvb_demux_feed
*feed
)
784 buf
[0] == 0x00 && buf
[1] == 0x00 && buf
[2] == 0x01)
786 case PROG_STREAM_MAP
:
787 case PRIVATE_STREAM2
:
788 case PROG_STREAM_DIR
:
791 case PADDING_STREAM
:
793 case ISO13522_STREAM
:
794 case PRIVATE_STREAM1
:
795 case AUDIO_STREAM_S
... AUDIO_STREAM_E
:
796 case VIDEO_STREAM_S
... VIDEO_STREAM_E
:
805 memset(obuf
, 0, TS_SIZE
);
806 if (length
- c
>= (TS_SIZE
- 4)){
807 l
= write_ts_header2(pid
, counter
, pes_start
,
808 obuf
, (TS_SIZE
- 4));
809 memcpy(obuf
+ l
, buf
+ c
, TS_SIZE
- l
);
812 l
= write_ts_header2(pid
, counter
, pes_start
,
814 memcpy(obuf
+ l
, buf
+ c
, TS_SIZE
- l
);
817 feed
->cb
.ts(obuf
, 188, NULL
, 0, &feed
->feed
.ts
, NULL
);
823 static int write_ts_to_decoder(struct av7110
*av7110
, int type
, const u8
*buf
, size_t len
)
825 struct ipack
*ipack
= &av7110
->ipack
[type
];
827 if (buf
[1] & TRANS_ERROR
) {
828 av7110_ipack_reset(ipack
);
832 if (!(buf
[3] & PAYLOAD
))
835 if (buf
[1] & PAY_START
)
836 av7110_ipack_flush(ipack
);
838 if (buf
[3] & ADAPT_FIELD
) {
845 av7110_ipack_instant_repack(buf
+ 4, len
- 4, ipack
);
850 int av7110_write_to_decoder(struct dvb_demux_feed
*feed
, const u8
*buf
, size_t len
)
852 struct dvb_demux
*demux
= feed
->demux
;
853 struct av7110
*av7110
= (struct av7110
*) demux
->priv
;
855 dprintk(2, "av7110:%p, \n", av7110
);
857 if (av7110
->full_ts
&& demux
->dmx
.frontend
->source
!= DMX_MEMORY_FE
)
860 switch (feed
->pes_type
) {
862 if (av7110
->audiostate
.stream_source
== AUDIO_SOURCE_MEMORY
)
866 if (av7110
->videostate
.stream_source
== VIDEO_SOURCE_MEMORY
)
873 return write_ts_to_decoder(av7110
, feed
->pes_type
, buf
, len
);
878 /******************************************************************************
879 * Video MPEG decoder events
880 ******************************************************************************/
881 void dvb_video_add_event(struct av7110
*av7110
, struct video_event
*event
)
883 struct dvb_video_events
*events
= &av7110
->video_events
;
886 spin_lock_bh(&events
->lock
);
888 wp
= (events
->eventw
+ 1) % MAX_VIDEO_EVENT
;
889 if (wp
== events
->eventr
) {
890 events
->overflow
= 1;
891 events
->eventr
= (events
->eventr
+ 1) % MAX_VIDEO_EVENT
;
895 memcpy(&events
->events
[events
->eventw
], event
, sizeof(struct video_event
));
898 spin_unlock_bh(&events
->lock
);
900 wake_up_interruptible(&events
->wait_queue
);
904 static int dvb_video_get_event (struct av7110
*av7110
, struct video_event
*event
, int flags
)
906 struct dvb_video_events
*events
= &av7110
->video_events
;
908 if (events
->overflow
) {
909 events
->overflow
= 0;
912 if (events
->eventw
== events
->eventr
) {
915 if (flags
& O_NONBLOCK
)
918 ret
= wait_event_interruptible(events
->wait_queue
,
919 events
->eventw
!= events
->eventr
);
924 spin_lock_bh(&events
->lock
);
926 memcpy(event
, &events
->events
[events
->eventr
],
927 sizeof(struct video_event
));
928 events
->eventr
= (events
->eventr
+ 1) % MAX_VIDEO_EVENT
;
930 spin_unlock_bh(&events
->lock
);
936 /******************************************************************************
937 * DVB device file operations
938 ******************************************************************************/
940 static __poll_t
dvb_video_poll(struct file
*file
, poll_table
*wait
)
942 struct dvb_device
*dvbdev
= file
->private_data
;
943 struct av7110
*av7110
= dvbdev
->priv
;
946 dprintk(2, "av7110:%p, \n", av7110
);
948 if ((file
->f_flags
& O_ACCMODE
) != O_RDONLY
)
949 poll_wait(file
, &av7110
->avout
.queue
, wait
);
951 poll_wait(file
, &av7110
->video_events
.wait_queue
, wait
);
953 if (av7110
->video_events
.eventw
!= av7110
->video_events
.eventr
)
956 if ((file
->f_flags
& O_ACCMODE
) != O_RDONLY
) {
957 if (av7110
->playing
) {
959 mask
|= (EPOLLOUT
| EPOLLWRNORM
);
961 /* if not playing: may play if asked for */
962 mask
|= (EPOLLOUT
| EPOLLWRNORM
);
969 static ssize_t
dvb_video_write(struct file
*file
, const char __user
*buf
,
970 size_t count
, loff_t
*ppos
)
972 struct dvb_device
*dvbdev
= file
->private_data
;
973 struct av7110
*av7110
= dvbdev
->priv
;
976 dprintk(2, "av7110:%p, \n", av7110
);
978 if ((file
->f_flags
& O_ACCMODE
) == O_RDONLY
)
981 if (av7110
->videostate
.stream_source
!= VIDEO_SOURCE_MEMORY
)
984 if (get_user(c
, buf
))
986 if (c
== 0x47 && count
% TS_SIZE
== 0)
987 return ts_play(av7110
, buf
, count
, file
->f_flags
& O_NONBLOCK
, 1);
989 return dvb_play(av7110
, buf
, count
, file
->f_flags
& O_NONBLOCK
, 1);
992 static __poll_t
dvb_audio_poll(struct file
*file
, poll_table
*wait
)
994 struct dvb_device
*dvbdev
= file
->private_data
;
995 struct av7110
*av7110
= dvbdev
->priv
;
998 dprintk(2, "av7110:%p, \n", av7110
);
1000 poll_wait(file
, &av7110
->aout
.queue
, wait
);
1002 if (av7110
->playing
) {
1003 if (dvb_ringbuffer_free(&av7110
->aout
) >= 20 * 1024)
1004 mask
|= (EPOLLOUT
| EPOLLWRNORM
);
1005 } else /* if not playing: may play if asked for */
1006 mask
= (EPOLLOUT
| EPOLLWRNORM
);
1011 static ssize_t
dvb_audio_write(struct file
*file
, const char __user
*buf
,
1012 size_t count
, loff_t
*ppos
)
1014 struct dvb_device
*dvbdev
= file
->private_data
;
1015 struct av7110
*av7110
= dvbdev
->priv
;
1018 dprintk(2, "av7110:%p, \n", av7110
);
1020 if (av7110
->audiostate
.stream_source
!= AUDIO_SOURCE_MEMORY
) {
1021 printk(KERN_ERR
"not audio source memory\n");
1025 if (get_user(c
, buf
))
1027 if (c
== 0x47 && count
% TS_SIZE
== 0)
1028 return ts_play(av7110
, buf
, count
, file
->f_flags
& O_NONBLOCK
, 0);
1030 return dvb_aplay(av7110
, buf
, count
, file
->f_flags
& O_NONBLOCK
, 0);
1033 static u8 iframe_header
[] = { 0x00, 0x00, 0x01, 0xe0, 0x00, 0x00, 0x80, 0x00, 0x00 };
1035 #define MIN_IFRAME 400000
1037 static int play_iframe(struct av7110
*av7110
, char __user
*buf
, unsigned int len
, int nonblock
)
1040 int progressive
= 0;
1043 dprintk(2, "av7110:%p, \n", av7110
);
1048 if (!(av7110
->playing
& RP_VIDEO
)) {
1049 if (av7110_av_start_play(av7110
, RP_VIDEO
) < 0)
1053 /* search in buf for instances of 00 00 01 b5 1? */
1054 for (i
= 0; i
< len
; i
++) {
1056 if (get_user(c
, buf
+ i
))
1059 progressive
= c
& 0x08;
1063 match
= (match
== 1 || match
== 2) ? 2 : 1;
1067 case 2: if (c
== 0x01)
1070 case 3: if (c
== 0xb5)
1073 case 4: if ((c
& 0xf0) == 0x10)
1080 /* setting n always > 1, fixes problems when playing stillframes
1081 consisting of I- and P-Frames */
1082 n
= MIN_IFRAME
/ len
+ 1;
1084 /* FIXME: nonblock? */
1085 dvb_play_kernel(av7110
, iframe_header
, sizeof(iframe_header
), 0, 1);
1087 for (i
= 0; i
< n
; i
++)
1088 dvb_play(av7110
, buf
, len
, 0, 1);
1090 av7110_ipack_flush(&av7110
->ipack
[1]);
1093 return vidcom(av7110
, AV_VIDEO_CMD_FREEZE
, 1);
1099 static int dvb_video_ioctl(struct file
*file
,
1100 unsigned int cmd
, void *parg
)
1102 struct dvb_device
*dvbdev
= file
->private_data
;
1103 struct av7110
*av7110
= dvbdev
->priv
;
1104 unsigned long arg
= (unsigned long) parg
;
1107 dprintk(1, "av7110:%p, cmd=%04x\n", av7110
,cmd
);
1109 if ((file
->f_flags
& O_ACCMODE
) == O_RDONLY
) {
1110 if ( cmd
!= VIDEO_GET_STATUS
&& cmd
!= VIDEO_GET_EVENT
&&
1111 cmd
!= VIDEO_GET_SIZE
) {
1116 if (mutex_lock_interruptible(&av7110
->ioctl_mutex
))
1117 return -ERESTARTSYS
;
1121 av7110
->videostate
.play_state
= VIDEO_STOPPED
;
1122 if (av7110
->videostate
.stream_source
== VIDEO_SOURCE_MEMORY
)
1123 ret
= av7110_av_stop(av7110
, RP_VIDEO
);
1125 ret
= vidcom(av7110
, AV_VIDEO_CMD_STOP
,
1126 av7110
->videostate
.video_blank
? 0 : 1);
1128 av7110
->trickmode
= TRICK_NONE
;
1132 av7110
->trickmode
= TRICK_NONE
;
1133 if (av7110
->videostate
.play_state
== VIDEO_FREEZED
) {
1134 av7110
->videostate
.play_state
= VIDEO_PLAYING
;
1135 ret
= vidcom(av7110
, AV_VIDEO_CMD_PLAY
, 0);
1139 if (av7110
->videostate
.stream_source
== VIDEO_SOURCE_MEMORY
) {
1140 if (av7110
->playing
== RP_AV
) {
1141 ret
= av7110_fw_cmd(av7110
, COMTYPE_REC_PLAY
, __Stop
, 0);
1144 av7110
->playing
&= ~RP_VIDEO
;
1146 ret
= av7110_av_start_play(av7110
, RP_VIDEO
);
1149 ret
= vidcom(av7110
, AV_VIDEO_CMD_PLAY
, 0);
1151 av7110
->videostate
.play_state
= VIDEO_PLAYING
;
1155 av7110
->videostate
.play_state
= VIDEO_FREEZED
;
1156 if (av7110
->playing
& RP_VIDEO
)
1157 ret
= av7110_fw_cmd(av7110
, COMTYPE_REC_PLAY
, __Pause
, 0);
1159 ret
= vidcom(av7110
, AV_VIDEO_CMD_FREEZE
, 1);
1161 av7110
->trickmode
= TRICK_FREEZE
;
1164 case VIDEO_CONTINUE
:
1165 if (av7110
->playing
& RP_VIDEO
)
1166 ret
= av7110_fw_cmd(av7110
, COMTYPE_REC_PLAY
, __Continue
, 0);
1168 ret
= vidcom(av7110
, AV_VIDEO_CMD_PLAY
, 0);
1170 av7110
->videostate
.play_state
= VIDEO_PLAYING
;
1171 av7110
->trickmode
= TRICK_NONE
;
1175 case VIDEO_SELECT_SOURCE
:
1176 av7110
->videostate
.stream_source
= (video_stream_source_t
) arg
;
1179 case VIDEO_SET_BLANK
:
1180 av7110
->videostate
.video_blank
= (int) arg
;
1183 case VIDEO_GET_STATUS
:
1184 memcpy(parg
, &av7110
->videostate
, sizeof(struct video_status
));
1187 case VIDEO_GET_EVENT
:
1188 ret
= dvb_video_get_event(av7110
, parg
, file
->f_flags
);
1191 case VIDEO_GET_SIZE
:
1192 memcpy(parg
, &av7110
->video_size
, sizeof(video_size_t
));
1195 case VIDEO_SET_DISPLAY_FORMAT
:
1197 video_displayformat_t format
= (video_displayformat_t
) arg
;
1199 case VIDEO_PAN_SCAN
:
1200 av7110
->display_panscan
= VID_PAN_SCAN_PREF
;
1202 case VIDEO_LETTER_BOX
:
1203 av7110
->display_panscan
= VID_VC_AND_PS_PREF
;
1205 case VIDEO_CENTER_CUT_OUT
:
1206 av7110
->display_panscan
= VID_CENTRE_CUT_PREF
;
1213 av7110
->videostate
.display_format
= format
;
1214 ret
= av7110_fw_cmd(av7110
, COMTYPE_ENCODER
, SetPanScanType
,
1215 1, av7110
->display_panscan
);
1219 case VIDEO_SET_FORMAT
:
1224 av7110
->display_ar
= arg
;
1225 ret
= av7110_fw_cmd(av7110
, COMTYPE_ENCODER
, SetMonitorType
,
1229 case VIDEO_STILLPICTURE
:
1231 struct video_still_picture
*pic
=
1232 (struct video_still_picture
*) parg
;
1233 av7110
->videostate
.stream_source
= VIDEO_SOURCE_MEMORY
;
1234 dvb_ringbuffer_flush_spinlock_wakeup(&av7110
->avout
);
1235 ret
= play_iframe(av7110
, pic
->iFrame
, pic
->size
,
1236 file
->f_flags
& O_NONBLOCK
);
1240 case VIDEO_FAST_FORWARD
:
1241 //note: arg is ignored by firmware
1242 if (av7110
->playing
& RP_VIDEO
)
1243 ret
= av7110_fw_cmd(av7110
, COMTYPE_REC_PLAY
,
1244 __Scan_I
, 2, AV_PES
, 0);
1246 ret
= vidcom(av7110
, AV_VIDEO_CMD_FFWD
, arg
);
1248 av7110
->trickmode
= TRICK_FAST
;
1249 av7110
->videostate
.play_state
= VIDEO_PLAYING
;
1253 case VIDEO_SLOWMOTION
:
1254 if (av7110
->playing
&RP_VIDEO
) {
1255 if (av7110
->trickmode
!= TRICK_SLOW
)
1256 ret
= av7110_fw_cmd(av7110
, COMTYPE_REC_PLAY
, __Slow
, 2, 0, 0);
1258 ret
= vidcom(av7110
, AV_VIDEO_CMD_SLOW
, arg
);
1260 ret
= vidcom(av7110
, AV_VIDEO_CMD_PLAY
, 0);
1262 ret
= vidcom(av7110
, AV_VIDEO_CMD_STOP
, 0);
1264 ret
= vidcom(av7110
, AV_VIDEO_CMD_SLOW
, arg
);
1267 av7110
->trickmode
= TRICK_SLOW
;
1268 av7110
->videostate
.play_state
= VIDEO_PLAYING
;
1272 case VIDEO_GET_CAPABILITIES
:
1273 *(int *)parg
= VIDEO_CAP_MPEG1
| VIDEO_CAP_MPEG2
|
1274 VIDEO_CAP_SYS
| VIDEO_CAP_PROG
;
1277 case VIDEO_CLEAR_BUFFER
:
1278 dvb_ringbuffer_flush_spinlock_wakeup(&av7110
->avout
);
1279 av7110_ipack_reset(&av7110
->ipack
[1]);
1280 if (av7110
->playing
== RP_AV
) {
1281 ret
= av7110_fw_cmd(av7110
, COMTYPE_REC_PLAY
,
1282 __Play
, 2, AV_PES
, 0);
1285 if (av7110
->trickmode
== TRICK_FAST
)
1286 ret
= av7110_fw_cmd(av7110
, COMTYPE_REC_PLAY
,
1287 __Scan_I
, 2, AV_PES
, 0);
1288 if (av7110
->trickmode
== TRICK_SLOW
) {
1289 ret
= av7110_fw_cmd(av7110
, COMTYPE_REC_PLAY
,
1292 ret
= vidcom(av7110
, AV_VIDEO_CMD_SLOW
, arg
);
1294 if (av7110
->trickmode
== TRICK_FREEZE
)
1295 ret
= vidcom(av7110
, AV_VIDEO_CMD_STOP
, 1);
1299 case VIDEO_SET_STREAMTYPE
:
1307 mutex_unlock(&av7110
->ioctl_mutex
);
1311 static int dvb_audio_ioctl(struct file
*file
,
1312 unsigned int cmd
, void *parg
)
1314 struct dvb_device
*dvbdev
= file
->private_data
;
1315 struct av7110
*av7110
= dvbdev
->priv
;
1316 unsigned long arg
= (unsigned long) parg
;
1319 dprintk(1, "av7110:%p, cmd=%04x\n", av7110
,cmd
);
1321 if (((file
->f_flags
& O_ACCMODE
) == O_RDONLY
) &&
1322 (cmd
!= AUDIO_GET_STATUS
))
1325 if (mutex_lock_interruptible(&av7110
->ioctl_mutex
))
1326 return -ERESTARTSYS
;
1330 if (av7110
->audiostate
.stream_source
== AUDIO_SOURCE_MEMORY
)
1331 ret
= av7110_av_stop(av7110
, RP_AUDIO
);
1333 ret
= audcom(av7110
, AUDIO_CMD_MUTE
);
1335 av7110
->audiostate
.play_state
= AUDIO_STOPPED
;
1339 if (av7110
->audiostate
.stream_source
== AUDIO_SOURCE_MEMORY
)
1340 ret
= av7110_av_start_play(av7110
, RP_AUDIO
);
1342 ret
= audcom(av7110
, AUDIO_CMD_UNMUTE
);
1344 av7110
->audiostate
.play_state
= AUDIO_PLAYING
;
1348 ret
= audcom(av7110
, AUDIO_CMD_MUTE
);
1350 av7110
->audiostate
.play_state
= AUDIO_PAUSED
;
1353 case AUDIO_CONTINUE
:
1354 if (av7110
->audiostate
.play_state
== AUDIO_PAUSED
) {
1355 av7110
->audiostate
.play_state
= AUDIO_PLAYING
;
1356 ret
= audcom(av7110
, AUDIO_CMD_UNMUTE
| AUDIO_CMD_PCM16
);
1360 case AUDIO_SELECT_SOURCE
:
1361 av7110
->audiostate
.stream_source
= (audio_stream_source_t
) arg
;
1364 case AUDIO_SET_MUTE
:
1366 ret
= audcom(av7110
, arg
? AUDIO_CMD_MUTE
: AUDIO_CMD_UNMUTE
);
1368 av7110
->audiostate
.mute_state
= (int) arg
;
1372 case AUDIO_SET_AV_SYNC
:
1373 av7110
->audiostate
.AV_sync_state
= (int) arg
;
1374 ret
= audcom(av7110
, arg
? AUDIO_CMD_SYNC_ON
: AUDIO_CMD_SYNC_OFF
);
1377 case AUDIO_SET_BYPASS_MODE
:
1378 if (FW_VERSION(av7110
->arm_app
) < 0x2621)
1380 av7110
->audiostate
.bypass_mode
= (int)arg
;
1383 case AUDIO_CHANNEL_SELECT
:
1384 av7110
->audiostate
.channel_select
= (audio_channel_select_t
) arg
;
1385 switch(av7110
->audiostate
.channel_select
) {
1387 ret
= audcom(av7110
, AUDIO_CMD_STEREO
);
1389 if (av7110
->adac_type
== DVB_ADAC_CRYSTAL
)
1390 i2c_writereg(av7110
, 0x20, 0x02, 0x49);
1391 else if (av7110
->adac_type
== DVB_ADAC_MSP34x5
)
1392 msp_writereg(av7110
, MSP_WR_DSP
, 0x0008, 0x0220);
1395 case AUDIO_MONO_LEFT
:
1396 ret
= audcom(av7110
, AUDIO_CMD_MONO_L
);
1398 if (av7110
->adac_type
== DVB_ADAC_CRYSTAL
)
1399 i2c_writereg(av7110
, 0x20, 0x02, 0x4a);
1400 else if (av7110
->adac_type
== DVB_ADAC_MSP34x5
)
1401 msp_writereg(av7110
, MSP_WR_DSP
, 0x0008, 0x0200);
1404 case AUDIO_MONO_RIGHT
:
1405 ret
= audcom(av7110
, AUDIO_CMD_MONO_R
);
1407 if (av7110
->adac_type
== DVB_ADAC_CRYSTAL
)
1408 i2c_writereg(av7110
, 0x20, 0x02, 0x45);
1409 else if (av7110
->adac_type
== DVB_ADAC_MSP34x5
)
1410 msp_writereg(av7110
, MSP_WR_DSP
, 0x0008, 0x0210);
1419 case AUDIO_GET_STATUS
:
1420 memcpy(parg
, &av7110
->audiostate
, sizeof(struct audio_status
));
1423 case AUDIO_GET_CAPABILITIES
:
1424 if (FW_VERSION(av7110
->arm_app
) < 0x2621)
1425 *(unsigned int *)parg
= AUDIO_CAP_LPCM
| AUDIO_CAP_MP1
| AUDIO_CAP_MP2
;
1427 *(unsigned int *)parg
= AUDIO_CAP_LPCM
| AUDIO_CAP_DTS
| AUDIO_CAP_AC3
|
1428 AUDIO_CAP_MP1
| AUDIO_CAP_MP2
;
1431 case AUDIO_CLEAR_BUFFER
:
1432 dvb_ringbuffer_flush_spinlock_wakeup(&av7110
->aout
);
1433 av7110_ipack_reset(&av7110
->ipack
[0]);
1434 if (av7110
->playing
== RP_AV
)
1435 ret
= av7110_fw_cmd(av7110
, COMTYPE_REC_PLAY
,
1436 __Play
, 2, AV_PES
, 0);
1442 case AUDIO_SET_MIXER
:
1444 struct audio_mixer
*amix
= (struct audio_mixer
*)parg
;
1445 ret
= av7110_set_volume(av7110
, amix
->volume_left
, amix
->volume_right
);
1449 case AUDIO_SET_STREAMTYPE
:
1456 mutex_unlock(&av7110
->ioctl_mutex
);
1461 static int dvb_video_open(struct inode
*inode
, struct file
*file
)
1463 struct dvb_device
*dvbdev
= file
->private_data
;
1464 struct av7110
*av7110
= dvbdev
->priv
;
1467 dprintk(2, "av7110:%p, \n", av7110
);
1469 if ((err
= dvb_generic_open(inode
, file
)) < 0)
1472 if ((file
->f_flags
& O_ACCMODE
) != O_RDONLY
) {
1473 dvb_ringbuffer_flush_spinlock_wakeup(&av7110
->aout
);
1474 dvb_ringbuffer_flush_spinlock_wakeup(&av7110
->avout
);
1475 av7110
->video_blank
= 1;
1476 av7110
->audiostate
.AV_sync_state
= 1;
1477 av7110
->videostate
.stream_source
= VIDEO_SOURCE_DEMUX
;
1479 /* empty event queue */
1480 av7110
->video_events
.eventr
= av7110
->video_events
.eventw
= 0;
1486 static int dvb_video_release(struct inode
*inode
, struct file
*file
)
1488 struct dvb_device
*dvbdev
= file
->private_data
;
1489 struct av7110
*av7110
= dvbdev
->priv
;
1491 dprintk(2, "av7110:%p, \n", av7110
);
1493 if ((file
->f_flags
& O_ACCMODE
) != O_RDONLY
) {
1494 av7110_av_stop(av7110
, RP_VIDEO
);
1497 return dvb_generic_release(inode
, file
);
1500 static int dvb_audio_open(struct inode
*inode
, struct file
*file
)
1502 struct dvb_device
*dvbdev
= file
->private_data
;
1503 struct av7110
*av7110
= dvbdev
->priv
;
1504 int err
= dvb_generic_open(inode
, file
);
1506 dprintk(2, "av7110:%p, \n", av7110
);
1510 dvb_ringbuffer_flush_spinlock_wakeup(&av7110
->aout
);
1511 av7110
->audiostate
.stream_source
= AUDIO_SOURCE_DEMUX
;
1515 static int dvb_audio_release(struct inode
*inode
, struct file
*file
)
1517 struct dvb_device
*dvbdev
= file
->private_data
;
1518 struct av7110
*av7110
= dvbdev
->priv
;
1520 dprintk(2, "av7110:%p, \n", av7110
);
1522 av7110_av_stop(av7110
, RP_AUDIO
);
1523 return dvb_generic_release(inode
, file
);
1528 /******************************************************************************
1529 * driver registration
1530 ******************************************************************************/
1532 static const struct file_operations dvb_video_fops
= {
1533 .owner
= THIS_MODULE
,
1534 .write
= dvb_video_write
,
1535 .unlocked_ioctl
= dvb_generic_ioctl
,
1536 .open
= dvb_video_open
,
1537 .release
= dvb_video_release
,
1538 .poll
= dvb_video_poll
,
1539 .llseek
= noop_llseek
,
1542 static struct dvb_device dvbdev_video
= {
1545 .readers
= 5, /* arbitrary */
1547 .fops
= &dvb_video_fops
,
1548 .kernel_ioctl
= dvb_video_ioctl
,
1551 static const struct file_operations dvb_audio_fops
= {
1552 .owner
= THIS_MODULE
,
1553 .write
= dvb_audio_write
,
1554 .unlocked_ioctl
= dvb_generic_ioctl
,
1555 .open
= dvb_audio_open
,
1556 .release
= dvb_audio_release
,
1557 .poll
= dvb_audio_poll
,
1558 .llseek
= noop_llseek
,
1561 static struct dvb_device dvbdev_audio
= {
1565 .fops
= &dvb_audio_fops
,
1566 .kernel_ioctl
= dvb_audio_ioctl
,
1570 int av7110_av_register(struct av7110
*av7110
)
1572 av7110
->audiostate
.AV_sync_state
= 0;
1573 av7110
->audiostate
.mute_state
= 0;
1574 av7110
->audiostate
.play_state
= AUDIO_STOPPED
;
1575 av7110
->audiostate
.stream_source
= AUDIO_SOURCE_DEMUX
;
1576 av7110
->audiostate
.channel_select
= AUDIO_STEREO
;
1577 av7110
->audiostate
.bypass_mode
= 0;
1579 av7110
->videostate
.video_blank
= 0;
1580 av7110
->videostate
.play_state
= VIDEO_STOPPED
;
1581 av7110
->videostate
.stream_source
= VIDEO_SOURCE_DEMUX
;
1582 av7110
->videostate
.video_format
= VIDEO_FORMAT_4_3
;
1583 av7110
->videostate
.display_format
= VIDEO_LETTER_BOX
;
1584 av7110
->display_ar
= VIDEO_FORMAT_4_3
;
1585 av7110
->display_panscan
= VID_VC_AND_PS_PREF
;
1587 init_waitqueue_head(&av7110
->video_events
.wait_queue
);
1588 spin_lock_init(&av7110
->video_events
.lock
);
1589 av7110
->video_events
.eventw
= av7110
->video_events
.eventr
= 0;
1590 av7110
->video_events
.overflow
= 0;
1591 memset(&av7110
->video_size
, 0, sizeof (video_size_t
));
1593 dvb_register_device(&av7110
->dvb_adapter
, &av7110
->video_dev
,
1594 &dvbdev_video
, av7110
, DVB_DEVICE_VIDEO
, 0);
1596 dvb_register_device(&av7110
->dvb_adapter
, &av7110
->audio_dev
,
1597 &dvbdev_audio
, av7110
, DVB_DEVICE_AUDIO
, 0);
1602 void av7110_av_unregister(struct av7110
*av7110
)
1604 dvb_unregister_device(av7110
->audio_dev
);
1605 dvb_unregister_device(av7110
->video_dev
);
1608 int av7110_av_init(struct av7110
*av7110
)
1610 void (*play
[])(u8
*, int, void *) = { play_audio_cb
, play_video_cb
};
1613 for (i
= 0; i
< 2; i
++) {
1614 struct ipack
*ipack
= av7110
->ipack
+ i
;
1616 ret
= av7110_ipack_init(ipack
, IPACKS
, play
[i
]);
1619 av7110_ipack_free(--ipack
);
1622 ipack
->data
= av7110
;
1625 dvb_ringbuffer_init(&av7110
->avout
, av7110
->iobuf
, AVOUTLEN
);
1626 dvb_ringbuffer_init(&av7110
->aout
, av7110
->iobuf
+ AVOUTLEN
, AOUTLEN
);
1628 av7110
->kbuf
[0] = (u8
*)(av7110
->iobuf
+ AVOUTLEN
+ AOUTLEN
+ BMPLEN
);
1629 av7110
->kbuf
[1] = av7110
->kbuf
[0] + 2 * IPACKS
;
1634 void av7110_av_exit(struct av7110
*av7110
)
1636 av7110_ipack_free(&av7110
->ipack
[0]);
1637 av7110_ipack_free(&av7110
->ipack
[1]);