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.
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
25 * Or, point your browser to http://www.gnu.org/copyleft/gpl.html
28 * the project's page is at http://www.linuxtv.org/
31 #include <linux/types.h>
32 #include <linux/kernel.h>
33 #include <linux/string.h>
34 #include <linux/delay.h>
38 #include "av7110_hw.h"
39 #include "av7110_av.h"
40 #include "av7110_ipack.h"
42 /* MPEG-2 (ISO 13818 / H.222.0) stream types */
43 #define PROG_STREAM_MAP 0xBC
44 #define PRIVATE_STREAM1 0xBD
45 #define PADDING_STREAM 0xBE
46 #define PRIVATE_STREAM2 0xBF
47 #define AUDIO_STREAM_S 0xC0
48 #define AUDIO_STREAM_E 0xDF
49 #define VIDEO_STREAM_S 0xE0
50 #define VIDEO_STREAM_E 0xEF
51 #define ECM_STREAM 0xF0
52 #define EMM_STREAM 0xF1
53 #define DSM_CC_STREAM 0xF2
54 #define ISO13522_STREAM 0xF3
55 #define PROG_STREAM_DIR 0xFF
57 #define PTS_DTS_FLAGS 0xC0
63 #define TRANS_ERROR 0x80
64 #define PAY_START 0x40
65 #define TRANS_PRIO 0x20
66 #define PID_MASK_HI 0x1F
68 #define TRANS_SCRMBL1 0x80
69 #define TRANS_SCRMBL2 0x40
70 #define ADAPT_FIELD 0x20
72 #define COUNT_MASK 0x0F
75 #define DISCON_IND 0x80
76 #define RAND_ACC_IND 0x40
77 #define ES_PRI_IND 0x20
79 #define OPCR_FLAG 0x08
80 #define SPLICE_FLAG 0x04
81 #define TRANS_PRIV 0x02
82 #define ADAP_EXT_FLAG 0x01
84 // adaptation extension flags
86 #define PIECE_RATE 0x40
87 #define SEAM_SPLICE 0x20
90 static void p_to_t(u8
const *buf
, long int length
, u16 pid
,
91 u8
*counter
, struct dvb_demux_feed
*feed
);
92 static int write_ts_to_decoder(struct av7110
*av7110
, int type
, const u8
*buf
, size_t len
);
95 int av7110_record_cb(struct dvb_filter_pes2ts
*p2t
, u8
*buf
, size_t len
)
97 struct dvb_demux_feed
*dvbdmxfeed
= (struct dvb_demux_feed
*) p2t
->priv
;
99 if (!(dvbdmxfeed
->ts_type
& TS_PACKET
))
101 if (buf
[3] == 0xe0) // video PES do not have a length in TS
103 if (dvbdmxfeed
->ts_type
& TS_PAYLOAD_ONLY
)
104 return dvbdmxfeed
->cb
.ts(buf
, len
, NULL
, 0,
105 &dvbdmxfeed
->feed
.ts
, DMX_OK
);
107 return dvb_filter_pes2ts(p2t
, buf
, len
, 1);
110 static int dvb_filter_pes2ts_cb(void *priv
, unsigned char *data
)
112 struct dvb_demux_feed
*dvbdmxfeed
= (struct dvb_demux_feed
*) priv
;
114 dvbdmxfeed
->cb
.ts(data
, 188, NULL
, 0,
115 &dvbdmxfeed
->feed
.ts
, DMX_OK
);
119 int av7110_av_start_record(struct av7110
*av7110
, int av
,
120 struct dvb_demux_feed
*dvbdmxfeed
)
123 struct dvb_demux
*dvbdmx
= dvbdmxfeed
->demux
;
125 dprintk(2, "av7110:%p, , dvb_demux_feed:%p\n", av7110
, dvbdmxfeed
);
127 if (av7110
->playing
|| (av7110
->rec_mode
& av
))
129 av7110_fw_cmd(av7110
, COMTYPE_REC_PLAY
, __Stop
, 0);
130 dvbdmx
->recording
= 1;
131 av7110
->rec_mode
|= av
;
133 switch (av7110
->rec_mode
) {
135 dvb_filter_pes2ts_init(&av7110
->p2t
[0],
136 dvbdmx
->pesfilter
[0]->pid
,
137 dvb_filter_pes2ts_cb
,
138 (void *) dvbdmx
->pesfilter
[0]);
139 ret
= av7110_fw_cmd(av7110
, COMTYPE_REC_PLAY
, __Record
, 2, AudioPES
, 0);
143 dvb_filter_pes2ts_init(&av7110
->p2t
[1],
144 dvbdmx
->pesfilter
[1]->pid
,
145 dvb_filter_pes2ts_cb
,
146 (void *) dvbdmx
->pesfilter
[1]);
147 ret
= av7110_fw_cmd(av7110
, COMTYPE_REC_PLAY
, __Record
, 2, VideoPES
, 0);
151 dvb_filter_pes2ts_init(&av7110
->p2t
[0],
152 dvbdmx
->pesfilter
[0]->pid
,
153 dvb_filter_pes2ts_cb
,
154 (void *) dvbdmx
->pesfilter
[0]);
155 dvb_filter_pes2ts_init(&av7110
->p2t
[1],
156 dvbdmx
->pesfilter
[1]->pid
,
157 dvb_filter_pes2ts_cb
,
158 (void *) dvbdmx
->pesfilter
[1]);
159 ret
= av7110_fw_cmd(av7110
, COMTYPE_REC_PLAY
, __Record
, 2, AV_PES
, 0);
165 int av7110_av_start_play(struct av7110
*av7110
, int av
)
168 dprintk(2, "av7110:%p, \n", av7110
);
170 if (av7110
->rec_mode
)
172 if (av7110
->playing
& av
)
175 av7110_fw_cmd(av7110
, COMTYPE_REC_PLAY
, __Stop
, 0);
177 if (av7110
->playing
== RP_NONE
) {
178 av7110_ipack_reset(&av7110
->ipack
[0]);
179 av7110_ipack_reset(&av7110
->ipack
[1]);
182 av7110
->playing
|= av
;
183 switch (av7110
->playing
) {
185 ret
= av7110_fw_cmd(av7110
, COMTYPE_REC_PLAY
, __Play
, 2, AudioPES
, 0);
188 ret
= av7110_fw_cmd(av7110
, COMTYPE_REC_PLAY
, __Play
, 2, VideoPES
, 0);
193 ret
= av7110_fw_cmd(av7110
, COMTYPE_REC_PLAY
, __Play
, 2, AV_PES
, 0);
199 int av7110_av_stop(struct av7110
*av7110
, int av
)
202 dprintk(2, "av7110:%p, \n", av7110
);
204 if (!(av7110
->playing
& av
) && !(av7110
->rec_mode
& av
))
206 av7110_fw_cmd(av7110
, COMTYPE_REC_PLAY
, __Stop
, 0);
207 if (av7110
->playing
) {
208 av7110
->playing
&= ~av
;
209 switch (av7110
->playing
) {
211 ret
= av7110_fw_cmd(av7110
, COMTYPE_REC_PLAY
, __Play
, 2, AudioPES
, 0);
214 ret
= av7110_fw_cmd(av7110
, COMTYPE_REC_PLAY
, __Play
, 2, VideoPES
, 0);
217 ret
= av7110_set_vidmode(av7110
, av7110
->vidmode
);
221 av7110
->rec_mode
&= ~av
;
222 switch (av7110
->rec_mode
) {
224 ret
= av7110_fw_cmd(av7110
, COMTYPE_REC_PLAY
, __Record
, 2, AudioPES
, 0);
227 ret
= av7110_fw_cmd(av7110
, COMTYPE_REC_PLAY
, __Record
, 2, VideoPES
, 0);
237 int av7110_pes_play(void *dest
, struct dvb_ringbuffer
*buf
, int dlen
)
244 wake_up(&buf
->queue
);
248 len
= dvb_ringbuffer_avail(buf
);
250 wake_up(&buf
->queue
);
253 sync
= DVB_RINGBUFFER_PEEK(buf
, 0) << 24;
254 sync
|= DVB_RINGBUFFER_PEEK(buf
, 1) << 16;
255 sync
|= DVB_RINGBUFFER_PEEK(buf
, 2) << 8;
256 sync
|= DVB_RINGBUFFER_PEEK(buf
, 3);
258 if (((sync
&~ 0x0f) == 0x000001e0) ||
259 ((sync
&~ 0x1f) == 0x000001c0) ||
260 (sync
== 0x000001bd))
263 DVB_RINGBUFFER_SKIP(buf
, 1);
265 blen
= DVB_RINGBUFFER_PEEK(buf
, 4) << 8;
266 blen
|= DVB_RINGBUFFER_PEEK(buf
, 5);
268 if (len
< blen
|| blen
> dlen
) {
269 //printk("buffer empty - avail %d blen %u dlen %d\n", len, blen, dlen);
270 wake_up(&buf
->queue
);
274 dvb_ringbuffer_read(buf
, dest
, (size_t) blen
);
276 dprintk(2, "pread=0x%08lx, pwrite=0x%08lx\n",
277 (unsigned long) buf
->pread
, (unsigned long) buf
->pwrite
);
278 wake_up(&buf
->queue
);
283 int av7110_set_volume(struct av7110
*av7110
, int volleft
, int volright
)
285 int err
, vol
, val
, balance
= 0;
287 dprintk(2, "av7110:%p, \n", av7110
);
289 av7110
->mixer
.volume_left
= volleft
;
290 av7110
->mixer
.volume_right
= volright
;
292 switch (av7110
->adac_type
) {
294 volleft
= (volleft
* 256) / 1036;
295 volright
= (volright
* 256) / 1036;
300 if ((err
= SendDAC(av7110
, 3, 0x80 + volleft
)))
302 return SendDAC(av7110
, 4, volright
);
304 case DVB_ADAC_CRYSTAL
:
305 volleft
= 127 - volleft
/ 2;
306 volright
= 127 - volright
/ 2;
307 i2c_writereg(av7110
, 0x20, 0x03, volleft
);
308 i2c_writereg(av7110
, 0x20, 0x04, volright
);
311 case DVB_ADAC_MSP34x0
:
312 vol
= (volleft
> volright
) ? volleft
: volright
;
313 val
= (vol
* 0x73 / 255) << 8;
315 balance
= ((volright
- volleft
) * 127) / vol
;
316 msp_writereg(av7110
, MSP_WR_DSP
, 0x0001, balance
<< 8);
317 msp_writereg(av7110
, MSP_WR_DSP
, 0x0000, val
); /* loudspeaker */
318 msp_writereg(av7110
, MSP_WR_DSP
, 0x0006, val
); /* headphonesr */
321 case DVB_ADAC_MSP34x5
:
322 vol
= (volleft
> volright
) ? volleft
: volright
;
323 val
= (vol
* 0x73 / 255) << 8;
325 balance
= ((volright
- volleft
) * 127) / vol
;
326 msp_writereg(av7110
, MSP_WR_DSP
, 0x0001, balance
<< 8);
327 msp_writereg(av7110
, MSP_WR_DSP
, 0x0000, val
); /* loudspeaker */
334 int av7110_set_vidmode(struct av7110
*av7110
, enum av7110_video_mode mode
)
337 dprintk(2, "av7110:%p, \n", av7110
);
339 ret
= av7110_fw_cmd(av7110
, COMTYPE_ENCODER
, LoadVidCode
, 1, mode
);
341 if (!ret
&& !av7110
->playing
) {
342 ret
= ChangePIDs(av7110
, av7110
->pids
[DMX_PES_VIDEO
],
343 av7110
->pids
[DMX_PES_AUDIO
],
344 av7110
->pids
[DMX_PES_TELETEXT
],
345 0, av7110
->pids
[DMX_PES_PCR
]);
347 ret
= av7110_fw_cmd(av7110
, COMTYPE_PIDFILTER
, Scan
, 0);
353 static enum av7110_video_mode sw2mode
[16] = {
354 AV7110_VIDEO_MODE_PAL
, AV7110_VIDEO_MODE_NTSC
,
355 AV7110_VIDEO_MODE_NTSC
, AV7110_VIDEO_MODE_PAL
,
356 AV7110_VIDEO_MODE_NTSC
, AV7110_VIDEO_MODE_NTSC
,
357 AV7110_VIDEO_MODE_PAL
, AV7110_VIDEO_MODE_NTSC
,
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
,
361 AV7110_VIDEO_MODE_PAL
, AV7110_VIDEO_MODE_PAL
,
364 static int get_video_format(struct av7110
*av7110
, u8
*buf
, int count
)
372 dprintk(2, "av7110:%p, \n", av7110
);
376 for (i
= 7; i
< count
- 10; i
++) {
378 if (p
[0] || p
[1] || p
[2] != 0x01 || p
[3] != 0xb3)
381 hsize
= ((p
[1] &0xF0) >> 4) | (p
[0] << 4);
382 vsize
= ((p
[1] &0x0F) << 8) | (p
[2]);
384 ret
= av7110_set_vidmode(av7110
, sw2mode
[sw
]);
386 dprintk(2, "playback %dx%d fr=%d\n", hsize
, vsize
, sw
);
395 /****************************************************************************
396 * I/O buffer management and control
397 ****************************************************************************/
399 static inline long aux_ring_buffer_write(struct dvb_ringbuffer
*rbuf
,
400 const u8
*buf
, unsigned long count
)
402 unsigned long todo
= count
;
406 if (dvb_ringbuffer_free(rbuf
) < 2048) {
407 if (wait_event_interruptible(rbuf
->queue
,
408 (dvb_ringbuffer_free(rbuf
) >= 2048)))
411 free
= dvb_ringbuffer_free(rbuf
);
414 dvb_ringbuffer_write(rbuf
, buf
, free
);
422 static void play_video_cb(u8
*buf
, int count
, void *priv
)
424 struct av7110
*av7110
= (struct av7110
*) priv
;
425 dprintk(2, "av7110:%p, \n", av7110
);
427 if ((buf
[3] & 0xe0) == 0xe0) {
428 get_video_format(av7110
, buf
, count
);
429 aux_ring_buffer_write(&av7110
->avout
, buf
, count
);
431 aux_ring_buffer_write(&av7110
->aout
, buf
, count
);
434 static void play_audio_cb(u8
*buf
, int count
, void *priv
)
436 struct av7110
*av7110
= (struct av7110
*) priv
;
437 dprintk(2, "av7110:%p, \n", av7110
);
439 aux_ring_buffer_write(&av7110
->aout
, buf
, count
);
443 #define FREE_COND_TS (dvb_ringbuffer_free(rb) >= 4096)
445 static ssize_t
ts_play(struct av7110
*av7110
, const char __user
*buf
,
446 unsigned long count
, int nonblock
, int type
)
448 struct dvb_ringbuffer
*rb
;
450 unsigned long todo
= count
;
452 dprintk(2, "%s: type %d cnt %lu\n", __func__
, type
, count
);
454 rb
= (type
) ? &av7110
->avout
: &av7110
->aout
;
455 kb
= av7110
->kbuf
[type
];
460 if (nonblock
&& !FREE_COND_TS
)
463 while (todo
>= TS_SIZE
) {
467 if (wait_event_interruptible(rb
->queue
, FREE_COND_TS
))
470 if (copy_from_user(kb
, buf
, TS_SIZE
))
472 write_ts_to_decoder(av7110
, type
, kb
, TS_SIZE
);
481 #define FREE_COND (dvb_ringbuffer_free(&av7110->avout) >= 20 * 1024 && \
482 dvb_ringbuffer_free(&av7110->aout) >= 20 * 1024)
484 static ssize_t
dvb_play(struct av7110
*av7110
, const char __user
*buf
,
485 unsigned long count
, int nonblock
, int type
)
487 unsigned long todo
= count
, n
;
488 dprintk(2, "av7110:%p, \n", av7110
);
490 if (!av7110
->kbuf
[type
])
493 if (nonblock
&& !FREE_COND
)
500 if (wait_event_interruptible(av7110
->avout
.queue
,
507 if (copy_from_user(av7110
->kbuf
[type
], buf
, n
))
509 av7110_ipack_instant_repack(av7110
->kbuf
[type
], n
,
510 &av7110
->ipack
[type
]);
517 static ssize_t
dvb_play_kernel(struct av7110
*av7110
, const u8
*buf
,
518 unsigned long count
, int nonblock
, int type
)
520 unsigned long todo
= count
, n
;
521 dprintk(2, "av7110:%p, \n", av7110
);
523 if (!av7110
->kbuf
[type
])
526 if (nonblock
&& !FREE_COND
)
533 if (wait_event_interruptible(av7110
->avout
.queue
,
540 av7110_ipack_instant_repack(buf
, n
, &av7110
->ipack
[type
]);
547 static ssize_t
dvb_aplay(struct av7110
*av7110
, const char __user
*buf
,
548 unsigned long count
, int nonblock
, int type
)
550 unsigned long todo
= count
, n
;
551 dprintk(2, "av7110:%p, \n", av7110
);
553 if (!av7110
->kbuf
[type
])
555 if (nonblock
&& dvb_ringbuffer_free(&av7110
->aout
) < 20 * 1024)
559 if (dvb_ringbuffer_free(&av7110
->aout
) < 20 * 1024) {
562 if (wait_event_interruptible(av7110
->aout
.queue
,
563 (dvb_ringbuffer_free(&av7110
->aout
) >= 20 * 1024)))
569 if (copy_from_user(av7110
->kbuf
[type
], buf
, n
))
571 av7110_ipack_instant_repack(av7110
->kbuf
[type
], n
,
572 &av7110
->ipack
[type
]);
579 void av7110_p2t_init(struct av7110_p2t
*p
, struct dvb_demux_feed
*feed
)
581 memset(p
->pes
, 0, TS_SIZE
);
589 static void clear_p2t(struct av7110_p2t
*p
)
591 memset(p
->pes
, 0, TS_SIZE
);
598 static int find_pes_header(u8
const *buf
, long int length
, int *frags
)
605 while (c
< length
- 3 && !found
) {
606 if (buf
[c
] == 0x00 && buf
[c
+ 1] == 0x00 &&
607 buf
[c
+ 2] == 0x01) {
608 switch ( buf
[c
+ 3] ) {
609 case PROG_STREAM_MAP
:
610 case PRIVATE_STREAM2
:
611 case PROG_STREAM_DIR
:
614 case PADDING_STREAM
:
616 case ISO13522_STREAM
:
617 case PRIVATE_STREAM1
:
618 case AUDIO_STREAM_S
... AUDIO_STREAM_E
:
619 case VIDEO_STREAM_S
... VIDEO_STREAM_E
:
630 if (c
== length
- 3 && !found
) {
631 if (buf
[length
- 1] == 0x00)
633 if (buf
[length
- 2] == 0x00 &&
634 buf
[length
- 1] == 0x00)
636 if (buf
[length
- 3] == 0x00 &&
637 buf
[length
- 2] == 0x00 &&
638 buf
[length
- 1] == 0x01)
646 void av7110_p2t_write(u8
const *buf
, long int length
, u16 pid
, struct av7110_p2t
*p
)
657 if (buf
[c
] == 0x00 && buf
[c
+ 1] == 0x01) {
663 if (buf
[c
] == 0x01) {
673 case PROG_STREAM_MAP
:
674 case PRIVATE_STREAM2
:
675 case PROG_STREAM_DIR
:
678 case PADDING_STREAM
:
680 case ISO13522_STREAM
:
681 case PRIVATE_STREAM1
:
682 case AUDIO_STREAM_S
... AUDIO_STREAM_E
:
683 case VIDEO_STREAM_S
... VIDEO_STREAM_E
:
689 memcpy(p
->pes
+ p
->pos
, buf
+ c
, (TS_SIZE
- 4) - p
->pos
);
690 c
+= (TS_SIZE
- 4) - p
->pos
;
691 p_to_t(p
->pes
, (TS_SIZE
- 4), pid
, &p
->counter
, p
->feed
);
704 c2
= find_pes_header(buf
+ c
, length
- c
, &p
->frags
);
705 if (c2
>= 0 && c2
< (TS_SIZE
- 4) - p
->pos
)
708 l
= (TS_SIZE
- 4) - p
->pos
;
709 memcpy(p
->pes
+ p
->pos
, buf
, l
);
712 p_to_t(p
->pes
, p
->pos
, pid
, &p
->counter
, p
->feed
);
718 c2
= find_pes_header(buf
+ c
+ add
, length
- c
- add
, &p
->frags
);
722 p_to_t(buf
+ c
, c2
- c
, pid
, &p
->counter
, p
->feed
);
730 rest
= l
% (TS_SIZE
- 4);
732 p_to_t(buf
+ c
, l
, pid
, &p
->counter
, p
->feed
);
733 memcpy(p
->pes
, buf
+ c
+ l
, rest
);
741 static int write_ts_header2(u16 pid
, u8
*counter
, int pes_start
, u8
*buf
, u8 length
)
746 u8 tshead
[4] = { 0x47, 0x00, 0x00, 0x10 };
748 fill
= (TS_SIZE
- 4) - length
;
753 tshead
[1] |= (u8
)((pid
& 0x1F00) >> 8);
754 tshead
[2] |= (u8
)(pid
& 0x00FF);
755 tshead
[3] |= ((*counter
)++ & 0x0F);
756 memcpy(buf
, tshead
, 4);
766 for (i
= 6; i
< fill
+ 4; i
++) {
776 static void p_to_t(u8
const *buf
, long int length
, u16 pid
, u8
*counter
,
777 struct dvb_demux_feed
*feed
)
785 buf
[0] == 0x00 && buf
[1] == 0x00 && buf
[2] == 0x01)
787 case PROG_STREAM_MAP
:
788 case PRIVATE_STREAM2
:
789 case PROG_STREAM_DIR
:
792 case PADDING_STREAM
:
794 case ISO13522_STREAM
:
795 case PRIVATE_STREAM1
:
796 case AUDIO_STREAM_S
... AUDIO_STREAM_E
:
797 case VIDEO_STREAM_S
... VIDEO_STREAM_E
:
806 memset(obuf
, 0, TS_SIZE
);
807 if (length
- c
>= (TS_SIZE
- 4)){
808 l
= write_ts_header2(pid
, counter
, pes_start
,
809 obuf
, (TS_SIZE
- 4));
810 memcpy(obuf
+ l
, buf
+ c
, TS_SIZE
- l
);
813 l
= write_ts_header2(pid
, counter
, pes_start
,
815 memcpy(obuf
+ l
, buf
+ c
, TS_SIZE
- l
);
818 feed
->cb
.ts(obuf
, 188, NULL
, 0, &feed
->feed
.ts
, DMX_OK
);
824 static int write_ts_to_decoder(struct av7110
*av7110
, int type
, const u8
*buf
, size_t len
)
826 struct ipack
*ipack
= &av7110
->ipack
[type
];
828 if (buf
[1] & TRANS_ERROR
) {
829 av7110_ipack_reset(ipack
);
833 if (!(buf
[3] & PAYLOAD
))
836 if (buf
[1] & PAY_START
)
837 av7110_ipack_flush(ipack
);
839 if (buf
[3] & ADAPT_FIELD
) {
846 av7110_ipack_instant_repack(buf
+ 4, len
- 4, ipack
);
851 int av7110_write_to_decoder(struct dvb_demux_feed
*feed
, const u8
*buf
, size_t len
)
853 struct dvb_demux
*demux
= feed
->demux
;
854 struct av7110
*av7110
= (struct av7110
*) demux
->priv
;
856 dprintk(2, "av7110:%p, \n", av7110
);
858 if (av7110
->full_ts
&& demux
->dmx
.frontend
->source
!= DMX_MEMORY_FE
)
861 switch (feed
->pes_type
) {
863 if (av7110
->audiostate
.stream_source
== AUDIO_SOURCE_MEMORY
)
867 if (av7110
->videostate
.stream_source
== VIDEO_SOURCE_MEMORY
)
874 return write_ts_to_decoder(av7110
, feed
->pes_type
, buf
, len
);
879 /******************************************************************************
880 * Video MPEG decoder events
881 ******************************************************************************/
882 void dvb_video_add_event(struct av7110
*av7110
, struct video_event
*event
)
884 struct dvb_video_events
*events
= &av7110
->video_events
;
887 spin_lock_bh(&events
->lock
);
889 wp
= (events
->eventw
+ 1) % MAX_VIDEO_EVENT
;
890 if (wp
== events
->eventr
) {
891 events
->overflow
= 1;
892 events
->eventr
= (events
->eventr
+ 1) % MAX_VIDEO_EVENT
;
896 memcpy(&events
->events
[events
->eventw
], event
, sizeof(struct video_event
));
899 spin_unlock_bh(&events
->lock
);
901 wake_up_interruptible(&events
->wait_queue
);
905 static int dvb_video_get_event (struct av7110
*av7110
, struct video_event
*event
, int flags
)
907 struct dvb_video_events
*events
= &av7110
->video_events
;
909 if (events
->overflow
) {
910 events
->overflow
= 0;
913 if (events
->eventw
== events
->eventr
) {
916 if (flags
& O_NONBLOCK
)
919 ret
= wait_event_interruptible(events
->wait_queue
,
920 events
->eventw
!= events
->eventr
);
925 spin_lock_bh(&events
->lock
);
927 memcpy(event
, &events
->events
[events
->eventr
],
928 sizeof(struct video_event
));
929 events
->eventr
= (events
->eventr
+ 1) % MAX_VIDEO_EVENT
;
931 spin_unlock_bh(&events
->lock
);
937 /******************************************************************************
938 * DVB device file operations
939 ******************************************************************************/
941 static unsigned int dvb_video_poll(struct file
*file
, poll_table
*wait
)
943 struct dvb_device
*dvbdev
= file
->private_data
;
944 struct av7110
*av7110
= dvbdev
->priv
;
945 unsigned int mask
= 0;
947 dprintk(2, "av7110:%p, \n", av7110
);
949 if ((file
->f_flags
& O_ACCMODE
) != O_RDONLY
)
950 poll_wait(file
, &av7110
->avout
.queue
, wait
);
952 poll_wait(file
, &av7110
->video_events
.wait_queue
, wait
);
954 if (av7110
->video_events
.eventw
!= av7110
->video_events
.eventr
)
957 if ((file
->f_flags
& O_ACCMODE
) != O_RDONLY
) {
958 if (av7110
->playing
) {
960 mask
|= (POLLOUT
| POLLWRNORM
);
961 } else /* if not playing: may play if asked for */
962 mask
|= (POLLOUT
| POLLWRNORM
);
968 static ssize_t
dvb_video_write(struct file
*file
, const char __user
*buf
,
969 size_t count
, loff_t
*ppos
)
971 struct dvb_device
*dvbdev
= file
->private_data
;
972 struct av7110
*av7110
= dvbdev
->priv
;
975 dprintk(2, "av7110:%p, \n", av7110
);
977 if ((file
->f_flags
& O_ACCMODE
) == O_RDONLY
)
980 if (av7110
->videostate
.stream_source
!= VIDEO_SOURCE_MEMORY
)
983 if (get_user(c
, buf
))
985 if (c
== 0x47 && count
% TS_SIZE
== 0)
986 return ts_play(av7110
, buf
, count
, file
->f_flags
& O_NONBLOCK
, 1);
988 return dvb_play(av7110
, buf
, count
, file
->f_flags
& O_NONBLOCK
, 1);
991 static unsigned int dvb_audio_poll(struct file
*file
, poll_table
*wait
)
993 struct dvb_device
*dvbdev
= file
->private_data
;
994 struct av7110
*av7110
= dvbdev
->priv
;
995 unsigned int mask
= 0;
997 dprintk(2, "av7110:%p, \n", av7110
);
999 poll_wait(file
, &av7110
->aout
.queue
, wait
);
1001 if (av7110
->playing
) {
1002 if (dvb_ringbuffer_free(&av7110
->aout
) >= 20 * 1024)
1003 mask
|= (POLLOUT
| POLLWRNORM
);
1004 } else /* if not playing: may play if asked for */
1005 mask
= (POLLOUT
| POLLWRNORM
);
1010 static ssize_t
dvb_audio_write(struct file
*file
, const char __user
*buf
,
1011 size_t count
, loff_t
*ppos
)
1013 struct dvb_device
*dvbdev
= file
->private_data
;
1014 struct av7110
*av7110
= dvbdev
->priv
;
1017 dprintk(2, "av7110:%p, \n", av7110
);
1019 if (av7110
->audiostate
.stream_source
!= AUDIO_SOURCE_MEMORY
) {
1020 printk(KERN_ERR
"not audio source memory\n");
1024 if (get_user(c
, buf
))
1026 if (c
== 0x47 && count
% TS_SIZE
== 0)
1027 return ts_play(av7110
, buf
, count
, file
->f_flags
& O_NONBLOCK
, 0);
1029 return dvb_aplay(av7110
, buf
, count
, file
->f_flags
& O_NONBLOCK
, 0);
1032 static u8 iframe_header
[] = { 0x00, 0x00, 0x01, 0xe0, 0x00, 0x00, 0x80, 0x00, 0x00 };
1034 #define MIN_IFRAME 400000
1036 static int play_iframe(struct av7110
*av7110
, char __user
*buf
, unsigned int len
, int nonblock
)
1039 int progressive
= 0;
1042 dprintk(2, "av7110:%p, \n", av7110
);
1044 if (!(av7110
->playing
& RP_VIDEO
)) {
1045 if (av7110_av_start_play(av7110
, RP_VIDEO
) < 0)
1049 /* search in buf for instances of 00 00 01 b5 1? */
1050 for (i
= 0; i
< len
; i
++) {
1052 if (get_user(c
, buf
+ i
))
1055 progressive
= c
& 0x08;
1059 match
= (match
== 1 || match
== 2) ? 2 : 1;
1063 case 2: if (c
== 0x01)
1066 case 3: if (c
== 0xb5)
1069 case 4: if ((c
& 0xf0) == 0x10)
1076 /* setting n always > 1, fixes problems when playing stillframes
1077 consisting of I- and P-Frames */
1078 n
= MIN_IFRAME
/ len
+ 1;
1080 /* FIXME: nonblock? */
1081 dvb_play_kernel(av7110
, iframe_header
, sizeof(iframe_header
), 0, 1);
1083 for (i
= 0; i
< n
; i
++)
1084 dvb_play(av7110
, buf
, len
, 0, 1);
1086 av7110_ipack_flush(&av7110
->ipack
[1]);
1089 return vidcom(av7110
, AV_VIDEO_CMD_FREEZE
, 1);
1095 static int dvb_video_ioctl(struct file
*file
,
1096 unsigned int cmd
, void *parg
)
1098 struct dvb_device
*dvbdev
= file
->private_data
;
1099 struct av7110
*av7110
= dvbdev
->priv
;
1100 unsigned long arg
= (unsigned long) parg
;
1103 dprintk(1, "av7110:%p, cmd=%04x\n", av7110
,cmd
);
1105 if ((file
->f_flags
& O_ACCMODE
) == O_RDONLY
) {
1106 if ( cmd
!= VIDEO_GET_STATUS
&& cmd
!= VIDEO_GET_EVENT
&&
1107 cmd
!= VIDEO_GET_SIZE
) {
1112 if (mutex_lock_interruptible(&av7110
->ioctl_mutex
))
1113 return -ERESTARTSYS
;
1117 av7110
->videostate
.play_state
= VIDEO_STOPPED
;
1118 if (av7110
->videostate
.stream_source
== VIDEO_SOURCE_MEMORY
)
1119 ret
= av7110_av_stop(av7110
, RP_VIDEO
);
1121 ret
= vidcom(av7110
, AV_VIDEO_CMD_STOP
,
1122 av7110
->videostate
.video_blank
? 0 : 1);
1124 av7110
->trickmode
= TRICK_NONE
;
1128 av7110
->trickmode
= TRICK_NONE
;
1129 if (av7110
->videostate
.play_state
== VIDEO_FREEZED
) {
1130 av7110
->videostate
.play_state
= VIDEO_PLAYING
;
1131 ret
= vidcom(av7110
, AV_VIDEO_CMD_PLAY
, 0);
1135 if (av7110
->videostate
.stream_source
== VIDEO_SOURCE_MEMORY
) {
1136 if (av7110
->playing
== RP_AV
) {
1137 ret
= av7110_fw_cmd(av7110
, COMTYPE_REC_PLAY
, __Stop
, 0);
1140 av7110
->playing
&= ~RP_VIDEO
;
1142 ret
= av7110_av_start_play(av7110
, RP_VIDEO
);
1145 ret
= vidcom(av7110
, AV_VIDEO_CMD_PLAY
, 0);
1147 av7110
->videostate
.play_state
= VIDEO_PLAYING
;
1151 av7110
->videostate
.play_state
= VIDEO_FREEZED
;
1152 if (av7110
->playing
& RP_VIDEO
)
1153 ret
= av7110_fw_cmd(av7110
, COMTYPE_REC_PLAY
, __Pause
, 0);
1155 ret
= vidcom(av7110
, AV_VIDEO_CMD_FREEZE
, 1);
1157 av7110
->trickmode
= TRICK_FREEZE
;
1160 case VIDEO_CONTINUE
:
1161 if (av7110
->playing
& RP_VIDEO
)
1162 ret
= av7110_fw_cmd(av7110
, COMTYPE_REC_PLAY
, __Continue
, 0);
1164 ret
= vidcom(av7110
, AV_VIDEO_CMD_PLAY
, 0);
1166 av7110
->videostate
.play_state
= VIDEO_PLAYING
;
1167 av7110
->trickmode
= TRICK_NONE
;
1171 case VIDEO_SELECT_SOURCE
:
1172 av7110
->videostate
.stream_source
= (video_stream_source_t
) arg
;
1175 case VIDEO_SET_BLANK
:
1176 av7110
->videostate
.video_blank
= (int) arg
;
1179 case VIDEO_GET_STATUS
:
1180 memcpy(parg
, &av7110
->videostate
, sizeof(struct video_status
));
1183 case VIDEO_GET_EVENT
:
1184 ret
= dvb_video_get_event(av7110
, parg
, file
->f_flags
);
1187 case VIDEO_GET_SIZE
:
1188 memcpy(parg
, &av7110
->video_size
, sizeof(video_size_t
));
1191 case VIDEO_SET_DISPLAY_FORMAT
:
1193 video_displayformat_t format
= (video_displayformat_t
) arg
;
1195 case VIDEO_PAN_SCAN
:
1196 av7110
->display_panscan
= VID_PAN_SCAN_PREF
;
1198 case VIDEO_LETTER_BOX
:
1199 av7110
->display_panscan
= VID_VC_AND_PS_PREF
;
1201 case VIDEO_CENTER_CUT_OUT
:
1202 av7110
->display_panscan
= VID_CENTRE_CUT_PREF
;
1209 av7110
->videostate
.display_format
= format
;
1210 ret
= av7110_fw_cmd(av7110
, COMTYPE_ENCODER
, SetPanScanType
,
1211 1, av7110
->display_panscan
);
1215 case VIDEO_SET_FORMAT
:
1220 av7110
->display_ar
= arg
;
1221 ret
= av7110_fw_cmd(av7110
, COMTYPE_ENCODER
, SetMonitorType
,
1225 case VIDEO_STILLPICTURE
:
1227 struct video_still_picture
*pic
=
1228 (struct video_still_picture
*) parg
;
1229 av7110
->videostate
.stream_source
= VIDEO_SOURCE_MEMORY
;
1230 dvb_ringbuffer_flush_spinlock_wakeup(&av7110
->avout
);
1231 ret
= play_iframe(av7110
, pic
->iFrame
, pic
->size
,
1232 file
->f_flags
& O_NONBLOCK
);
1236 case VIDEO_FAST_FORWARD
:
1237 //note: arg is ignored by firmware
1238 if (av7110
->playing
& RP_VIDEO
)
1239 ret
= av7110_fw_cmd(av7110
, COMTYPE_REC_PLAY
,
1240 __Scan_I
, 2, AV_PES
, 0);
1242 ret
= vidcom(av7110
, AV_VIDEO_CMD_FFWD
, arg
);
1244 av7110
->trickmode
= TRICK_FAST
;
1245 av7110
->videostate
.play_state
= VIDEO_PLAYING
;
1249 case VIDEO_SLOWMOTION
:
1250 if (av7110
->playing
&RP_VIDEO
) {
1251 if (av7110
->trickmode
!= TRICK_SLOW
)
1252 ret
= av7110_fw_cmd(av7110
, COMTYPE_REC_PLAY
, __Slow
, 2, 0, 0);
1254 ret
= vidcom(av7110
, AV_VIDEO_CMD_SLOW
, arg
);
1256 ret
= vidcom(av7110
, AV_VIDEO_CMD_PLAY
, 0);
1258 ret
= vidcom(av7110
, AV_VIDEO_CMD_STOP
, 0);
1260 ret
= vidcom(av7110
, AV_VIDEO_CMD_SLOW
, arg
);
1263 av7110
->trickmode
= TRICK_SLOW
;
1264 av7110
->videostate
.play_state
= VIDEO_PLAYING
;
1268 case VIDEO_GET_CAPABILITIES
:
1269 *(int *)parg
= VIDEO_CAP_MPEG1
| VIDEO_CAP_MPEG2
|
1270 VIDEO_CAP_SYS
| VIDEO_CAP_PROG
;
1273 case VIDEO_CLEAR_BUFFER
:
1274 dvb_ringbuffer_flush_spinlock_wakeup(&av7110
->avout
);
1275 av7110_ipack_reset(&av7110
->ipack
[1]);
1276 if (av7110
->playing
== RP_AV
) {
1277 ret
= av7110_fw_cmd(av7110
, COMTYPE_REC_PLAY
,
1278 __Play
, 2, AV_PES
, 0);
1281 if (av7110
->trickmode
== TRICK_FAST
)
1282 ret
= av7110_fw_cmd(av7110
, COMTYPE_REC_PLAY
,
1283 __Scan_I
, 2, AV_PES
, 0);
1284 if (av7110
->trickmode
== TRICK_SLOW
) {
1285 ret
= av7110_fw_cmd(av7110
, COMTYPE_REC_PLAY
,
1288 ret
= vidcom(av7110
, AV_VIDEO_CMD_SLOW
, arg
);
1290 if (av7110
->trickmode
== TRICK_FREEZE
)
1291 ret
= vidcom(av7110
, AV_VIDEO_CMD_STOP
, 1);
1295 case VIDEO_SET_STREAMTYPE
:
1303 mutex_unlock(&av7110
->ioctl_mutex
);
1307 static int dvb_audio_ioctl(struct file
*file
,
1308 unsigned int cmd
, void *parg
)
1310 struct dvb_device
*dvbdev
= file
->private_data
;
1311 struct av7110
*av7110
= dvbdev
->priv
;
1312 unsigned long arg
= (unsigned long) parg
;
1315 dprintk(1, "av7110:%p, cmd=%04x\n", av7110
,cmd
);
1317 if (((file
->f_flags
& O_ACCMODE
) == O_RDONLY
) &&
1318 (cmd
!= AUDIO_GET_STATUS
))
1321 if (mutex_lock_interruptible(&av7110
->ioctl_mutex
))
1322 return -ERESTARTSYS
;
1326 if (av7110
->audiostate
.stream_source
== AUDIO_SOURCE_MEMORY
)
1327 ret
= av7110_av_stop(av7110
, RP_AUDIO
);
1329 ret
= audcom(av7110
, AUDIO_CMD_MUTE
);
1331 av7110
->audiostate
.play_state
= AUDIO_STOPPED
;
1335 if (av7110
->audiostate
.stream_source
== AUDIO_SOURCE_MEMORY
)
1336 ret
= av7110_av_start_play(av7110
, RP_AUDIO
);
1338 ret
= audcom(av7110
, AUDIO_CMD_UNMUTE
);
1340 av7110
->audiostate
.play_state
= AUDIO_PLAYING
;
1344 ret
= audcom(av7110
, AUDIO_CMD_MUTE
);
1346 av7110
->audiostate
.play_state
= AUDIO_PAUSED
;
1349 case AUDIO_CONTINUE
:
1350 if (av7110
->audiostate
.play_state
== AUDIO_PAUSED
) {
1351 av7110
->audiostate
.play_state
= AUDIO_PLAYING
;
1352 ret
= audcom(av7110
, AUDIO_CMD_UNMUTE
| AUDIO_CMD_PCM16
);
1356 case AUDIO_SELECT_SOURCE
:
1357 av7110
->audiostate
.stream_source
= (audio_stream_source_t
) arg
;
1360 case AUDIO_SET_MUTE
:
1362 ret
= audcom(av7110
, arg
? AUDIO_CMD_MUTE
: AUDIO_CMD_UNMUTE
);
1364 av7110
->audiostate
.mute_state
= (int) arg
;
1368 case AUDIO_SET_AV_SYNC
:
1369 av7110
->audiostate
.AV_sync_state
= (int) arg
;
1370 ret
= audcom(av7110
, arg
? AUDIO_CMD_SYNC_ON
: AUDIO_CMD_SYNC_OFF
);
1373 case AUDIO_SET_BYPASS_MODE
:
1374 if (FW_VERSION(av7110
->arm_app
) < 0x2621)
1376 av7110
->audiostate
.bypass_mode
= (int)arg
;
1379 case AUDIO_CHANNEL_SELECT
:
1380 av7110
->audiostate
.channel_select
= (audio_channel_select_t
) arg
;
1381 switch(av7110
->audiostate
.channel_select
) {
1383 ret
= audcom(av7110
, AUDIO_CMD_STEREO
);
1385 if (av7110
->adac_type
== DVB_ADAC_CRYSTAL
)
1386 i2c_writereg(av7110
, 0x20, 0x02, 0x49);
1387 else if (av7110
->adac_type
== DVB_ADAC_MSP34x5
)
1388 msp_writereg(av7110
, MSP_WR_DSP
, 0x0008, 0x0220);
1391 case AUDIO_MONO_LEFT
:
1392 ret
= audcom(av7110
, AUDIO_CMD_MONO_L
);
1394 if (av7110
->adac_type
== DVB_ADAC_CRYSTAL
)
1395 i2c_writereg(av7110
, 0x20, 0x02, 0x4a);
1396 else if (av7110
->adac_type
== DVB_ADAC_MSP34x5
)
1397 msp_writereg(av7110
, MSP_WR_DSP
, 0x0008, 0x0200);
1400 case AUDIO_MONO_RIGHT
:
1401 ret
= audcom(av7110
, AUDIO_CMD_MONO_R
);
1403 if (av7110
->adac_type
== DVB_ADAC_CRYSTAL
)
1404 i2c_writereg(av7110
, 0x20, 0x02, 0x45);
1405 else if (av7110
->adac_type
== DVB_ADAC_MSP34x5
)
1406 msp_writereg(av7110
, MSP_WR_DSP
, 0x0008, 0x0210);
1415 case AUDIO_GET_STATUS
:
1416 memcpy(parg
, &av7110
->audiostate
, sizeof(struct audio_status
));
1419 case AUDIO_GET_CAPABILITIES
:
1420 if (FW_VERSION(av7110
->arm_app
) < 0x2621)
1421 *(unsigned int *)parg
= AUDIO_CAP_LPCM
| AUDIO_CAP_MP1
| AUDIO_CAP_MP2
;
1423 *(unsigned int *)parg
= AUDIO_CAP_LPCM
| AUDIO_CAP_DTS
| AUDIO_CAP_AC3
|
1424 AUDIO_CAP_MP1
| AUDIO_CAP_MP2
;
1427 case AUDIO_CLEAR_BUFFER
:
1428 dvb_ringbuffer_flush_spinlock_wakeup(&av7110
->aout
);
1429 av7110_ipack_reset(&av7110
->ipack
[0]);
1430 if (av7110
->playing
== RP_AV
)
1431 ret
= av7110_fw_cmd(av7110
, COMTYPE_REC_PLAY
,
1432 __Play
, 2, AV_PES
, 0);
1438 case AUDIO_SET_MIXER
:
1440 struct audio_mixer
*amix
= (struct audio_mixer
*)parg
;
1441 ret
= av7110_set_volume(av7110
, amix
->volume_left
, amix
->volume_right
);
1445 case AUDIO_SET_STREAMTYPE
:
1452 mutex_unlock(&av7110
->ioctl_mutex
);
1457 static int dvb_video_open(struct inode
*inode
, struct file
*file
)
1459 struct dvb_device
*dvbdev
= file
->private_data
;
1460 struct av7110
*av7110
= dvbdev
->priv
;
1463 dprintk(2, "av7110:%p, \n", av7110
);
1465 if ((err
= dvb_generic_open(inode
, file
)) < 0)
1468 if ((file
->f_flags
& O_ACCMODE
) != O_RDONLY
) {
1469 dvb_ringbuffer_flush_spinlock_wakeup(&av7110
->aout
);
1470 dvb_ringbuffer_flush_spinlock_wakeup(&av7110
->avout
);
1471 av7110
->video_blank
= 1;
1472 av7110
->audiostate
.AV_sync_state
= 1;
1473 av7110
->videostate
.stream_source
= VIDEO_SOURCE_DEMUX
;
1475 /* empty event queue */
1476 av7110
->video_events
.eventr
= av7110
->video_events
.eventw
= 0;
1482 static int dvb_video_release(struct inode
*inode
, struct file
*file
)
1484 struct dvb_device
*dvbdev
= file
->private_data
;
1485 struct av7110
*av7110
= dvbdev
->priv
;
1487 dprintk(2, "av7110:%p, \n", av7110
);
1489 if ((file
->f_flags
& O_ACCMODE
) != O_RDONLY
) {
1490 av7110_av_stop(av7110
, RP_VIDEO
);
1493 return dvb_generic_release(inode
, file
);
1496 static int dvb_audio_open(struct inode
*inode
, struct file
*file
)
1498 struct dvb_device
*dvbdev
= file
->private_data
;
1499 struct av7110
*av7110
= dvbdev
->priv
;
1500 int err
= dvb_generic_open(inode
, file
);
1502 dprintk(2, "av7110:%p, \n", av7110
);
1506 dvb_ringbuffer_flush_spinlock_wakeup(&av7110
->aout
);
1507 av7110
->audiostate
.stream_source
= AUDIO_SOURCE_DEMUX
;
1511 static int dvb_audio_release(struct inode
*inode
, struct file
*file
)
1513 struct dvb_device
*dvbdev
= file
->private_data
;
1514 struct av7110
*av7110
= dvbdev
->priv
;
1516 dprintk(2, "av7110:%p, \n", av7110
);
1518 av7110_av_stop(av7110
, RP_AUDIO
);
1519 return dvb_generic_release(inode
, file
);
1524 /******************************************************************************
1525 * driver registration
1526 ******************************************************************************/
1528 static const struct file_operations dvb_video_fops
= {
1529 .owner
= THIS_MODULE
,
1530 .write
= dvb_video_write
,
1531 .unlocked_ioctl
= dvb_generic_ioctl
,
1532 .open
= dvb_video_open
,
1533 .release
= dvb_video_release
,
1534 .poll
= dvb_video_poll
,
1535 .llseek
= noop_llseek
,
1538 static struct dvb_device dvbdev_video
= {
1541 .readers
= 5, /* arbitrary */
1543 .fops
= &dvb_video_fops
,
1544 .kernel_ioctl
= dvb_video_ioctl
,
1547 static const struct file_operations dvb_audio_fops
= {
1548 .owner
= THIS_MODULE
,
1549 .write
= dvb_audio_write
,
1550 .unlocked_ioctl
= dvb_generic_ioctl
,
1551 .open
= dvb_audio_open
,
1552 .release
= dvb_audio_release
,
1553 .poll
= dvb_audio_poll
,
1554 .llseek
= noop_llseek
,
1557 static struct dvb_device dvbdev_audio
= {
1561 .fops
= &dvb_audio_fops
,
1562 .kernel_ioctl
= dvb_audio_ioctl
,
1566 int av7110_av_register(struct av7110
*av7110
)
1568 av7110
->audiostate
.AV_sync_state
= 0;
1569 av7110
->audiostate
.mute_state
= 0;
1570 av7110
->audiostate
.play_state
= AUDIO_STOPPED
;
1571 av7110
->audiostate
.stream_source
= AUDIO_SOURCE_DEMUX
;
1572 av7110
->audiostate
.channel_select
= AUDIO_STEREO
;
1573 av7110
->audiostate
.bypass_mode
= 0;
1575 av7110
->videostate
.video_blank
= 0;
1576 av7110
->videostate
.play_state
= VIDEO_STOPPED
;
1577 av7110
->videostate
.stream_source
= VIDEO_SOURCE_DEMUX
;
1578 av7110
->videostate
.video_format
= VIDEO_FORMAT_4_3
;
1579 av7110
->videostate
.display_format
= VIDEO_LETTER_BOX
;
1580 av7110
->display_ar
= VIDEO_FORMAT_4_3
;
1581 av7110
->display_panscan
= VID_VC_AND_PS_PREF
;
1583 init_waitqueue_head(&av7110
->video_events
.wait_queue
);
1584 spin_lock_init(&av7110
->video_events
.lock
);
1585 av7110
->video_events
.eventw
= av7110
->video_events
.eventr
= 0;
1586 av7110
->video_events
.overflow
= 0;
1587 memset(&av7110
->video_size
, 0, sizeof (video_size_t
));
1589 dvb_register_device(&av7110
->dvb_adapter
, &av7110
->video_dev
,
1590 &dvbdev_video
, av7110
, DVB_DEVICE_VIDEO
);
1592 dvb_register_device(&av7110
->dvb_adapter
, &av7110
->audio_dev
,
1593 &dvbdev_audio
, av7110
, DVB_DEVICE_AUDIO
);
1598 void av7110_av_unregister(struct av7110
*av7110
)
1600 dvb_unregister_device(av7110
->audio_dev
);
1601 dvb_unregister_device(av7110
->video_dev
);
1604 int av7110_av_init(struct av7110
*av7110
)
1606 void (*play
[])(u8
*, int, void *) = { play_audio_cb
, play_video_cb
};
1609 for (i
= 0; i
< 2; i
++) {
1610 struct ipack
*ipack
= av7110
->ipack
+ i
;
1612 ret
= av7110_ipack_init(ipack
, IPACKS
, play
[i
]);
1615 av7110_ipack_free(--ipack
);
1618 ipack
->data
= av7110
;
1621 dvb_ringbuffer_init(&av7110
->avout
, av7110
->iobuf
, AVOUTLEN
);
1622 dvb_ringbuffer_init(&av7110
->aout
, av7110
->iobuf
+ AVOUTLEN
, AOUTLEN
);
1624 av7110
->kbuf
[0] = (u8
*)(av7110
->iobuf
+ AVOUTLEN
+ AOUTLEN
+ BMPLEN
);
1625 av7110
->kbuf
[1] = av7110
->kbuf
[0] + 2 * IPACKS
;
1630 void av7110_av_exit(struct av7110
*av7110
)
1632 av7110_ipack_free(&av7110
->ipack
[0]);
1633 av7110_ipack_free(&av7110
->ipack
[1]);