Lines Matching defs:av7110
37 #include "av7110.h"
92 static int write_ts_to_decoder(struct av7110 *av7110, int type, const u8 *buf, size_t len);
119 int av7110_av_start_record(struct av7110 *av7110, int av,
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);
131 av7110->rec_mode |= av;
133 switch (av7110->rec_mode) {
135 dvb_filter_pes2ts_init(&av7110->p2t[0],
139 ret = av7110_fw_cmd(av7110, COMTYPE_REC_PLAY, __Record, 2, AudioPES, 0);
143 dvb_filter_pes2ts_init(&av7110->p2t[1],
147 ret = av7110_fw_cmd(av7110, COMTYPE_REC_PLAY, __Record, 2, VideoPES, 0);
151 dvb_filter_pes2ts_init(&av7110->p2t[0],
155 dvb_filter_pes2ts_init(&av7110->p2t[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);
189 av7110->sinfo = 0;
192 av7110->sinfo = 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);
280 int av7110_set_volume(struct av7110 *av7110, int volleft, int volright)
284 dprintk(2, "av7110:%p, \n", av7110);
286 av7110->mixer.volume_left = volleft;
287 av7110->mixer.volume_right = volright;
289 switch (av7110->adac_type) {
297 if ((err = SendDAC(av7110, 3, 0x80 + volleft)))
299 return SendDAC(av7110, 4, volright);
304 i2c_writereg(av7110, 0x20, 0x03, volleft);
305 i2c_writereg(av7110, 0x20, 0x04, volright);
313 msp_writereg(av7110, MSP_WR_DSP, 0x0001, balance << 8);
314 msp_writereg(av7110, MSP_WR_DSP, 0x0000, val); /* loudspeaker */
315 msp_writereg(av7110, MSP_WR_DSP, 0x0006, val); /* headphonesr */
323 msp_writereg(av7110, MSP_WR_DSP, 0x0001, balance << 8);
324 msp_writereg(av7110, MSP_WR_DSP, 0x0000, val); /* loudspeaker */
331 int av7110_set_vidmode(struct av7110 *av7110, enum av7110_video_mode mode)
334 dprintk(2, "av7110:%p, \n", av7110);
336 ret = av7110_fw_cmd(av7110, COMTYPE_ENCODER, LoadVidCode, 1, mode);
338 if (!ret && !av7110->playing) {
339 ret = ChangePIDs(av7110, av7110->pids[DMX_PES_VIDEO],
340 av7110->pids[DMX_PES_AUDIO],
341 av7110->pids[DMX_PES_TELETEXT],
342 0, av7110->pids[DMX_PES_PCR]);
344 ret = av7110_fw_cmd(av7110, COMTYPE_PIDFILTER, Scan, 0);
361 static int get_video_format(struct av7110 *av7110, u8 *buf, int count)
369 dprintk(2, "av7110:%p, \n", av7110);
371 if (av7110->sinfo)
381 ret = av7110_set_vidmode(av7110, sw2mode[sw]);
384 av7110->sinfo = 1;
421 struct av7110 *av7110 = (struct av7110 *) priv;
422 dprintk(2, "av7110:%p, \n", av7110);
425 get_video_format(av7110, buf, count);
426 aux_ring_buffer_write(&av7110->avout, buf, count);
428 aux_ring_buffer_write(&av7110->aout, buf, count);
433 struct av7110 *av7110 = (struct av7110 *) priv;
434 dprintk(2, "av7110:%p, \n", av7110);
436 aux_ring_buffer_write(&av7110->aout, buf, count);
442 static ssize_t ts_play(struct av7110 *av7110, const char __user *buf,
451 rb = (type) ? &av7110->avout : &av7110->aout;
452 kb = av7110->kbuf[type];
469 write_ts_to_decoder(av7110, type, kb, TS_SIZE);
478 #define FREE_COND (dvb_ringbuffer_free(&av7110->avout) >= 20 * 1024 && \
479 dvb_ringbuffer_free(&av7110->aout) >= 20 * 1024)
481 static ssize_t dvb_play(struct av7110 *av7110, const char __user *buf,
485 dprintk(2, "av7110:%p, \n", av7110);
487 if (!av7110->kbuf[type])
497 if (wait_event_interruptible(av7110->avout.queue,
504 if (copy_from_user(av7110->kbuf[type], buf, n))
506 av7110_ipack_instant_repack(av7110->kbuf[type], n,
507 &av7110->ipack[type]);
514 static ssize_t dvb_play_kernel(struct av7110 *av7110, const u8 *buf,
518 dprintk(2, "av7110:%p, \n", av7110);
520 if (!av7110->kbuf[type])
530 if (wait_event_interruptible(av7110->avout.queue,
537 av7110_ipack_instant_repack(buf, n, &av7110->ipack[type]);
544 static ssize_t dvb_aplay(struct av7110 *av7110, const char __user *buf,
548 dprintk(2, "av7110:%p, \n", av7110);
550 if (!av7110->kbuf[type])
552 if (nonblock && dvb_ringbuffer_free(&av7110->aout) < 20 * 1024)
556 if (dvb_ringbuffer_free(&av7110->aout) < 20 * 1024) {
559 if (wait_event_interruptible(av7110->aout.queue,
560 (dvb_ringbuffer_free(&av7110->aout) >= 20 * 1024)))
566 if (copy_from_user(av7110->kbuf[type], buf, n))
568 av7110_ipack_instant_repack(av7110->kbuf[type], n,
569 &av7110->ipack[type]);
821 static int write_ts_to_decoder(struct av7110 *av7110, int type, const u8 *buf, size_t len)
823 struct ipack *ipack = &av7110->ipack[type];
851 struct av7110 *av7110 = (struct av7110 *) demux->priv;
853 dprintk(2, "av7110:%p, \n", av7110);
855 if (av7110->full_ts && demux->dmx.frontend->source != DMX_MEMORY_FE)
860 if (av7110->audiostate.stream_source == AUDIO_SOURCE_MEMORY)
864 if (av7110->videostate.stream_source == VIDEO_SOURCE_MEMORY)
871 return write_ts_to_decoder(av7110, feed->pes_type, buf, len);
879 void dvb_video_add_event(struct av7110 *av7110, struct video_event *event)
881 struct dvb_video_events *events = &av7110->video_events;
901 static int dvb_video_get_event (struct av7110 *av7110, struct video_event *event, int flags)
903 struct dvb_video_events *events = &av7110->video_events;
940 struct av7110 *av7110 = dvbdev->priv;
943 dprintk(2, "av7110:%p, \n", av7110);
946 poll_wait(file, &av7110->avout.queue, wait);
948 poll_wait(file, &av7110->video_events.wait_queue, wait);
950 if (av7110->video_events.eventw != av7110->video_events.eventr)
954 if (av7110->playing) {
968 struct av7110 *av7110 = dvbdev->priv;
971 dprintk(2, "av7110:%p, \n", av7110);
976 if (av7110->videostate.stream_source != VIDEO_SOURCE_MEMORY)
982 return ts_play(av7110, buf, count, file->f_flags & O_NONBLOCK, 1);
984 return dvb_play(av7110, buf, count, file->f_flags & O_NONBLOCK, 1);
990 struct av7110 *av7110 = dvbdev->priv;
993 dprintk(2, "av7110:%p, \n", av7110);
995 poll_wait(file, &av7110->aout.queue, wait);
997 if (av7110->playing) {
998 if (dvb_ringbuffer_free(&av7110->aout) >= 20 * 1024)
1010 struct av7110 *av7110 = dvbdev->priv;
1013 dprintk(2, "av7110:%p, \n", av7110);
1015 if (av7110->audiostate.stream_source != AUDIO_SOURCE_MEMORY) {
1023 return ts_play(av7110, buf, count, file->f_flags & O_NONBLOCK, 0);
1025 return dvb_aplay(av7110, buf, count, file->f_flags & O_NONBLOCK, 0);
1032 static int play_iframe(struct av7110 *av7110, char __user *buf, unsigned int len, int nonblock)
1038 dprintk(2, "av7110:%p, \n", av7110);
1040 if (!(av7110->playing & RP_VIDEO)) {
1041 if (av7110_av_start_play(av7110, RP_VIDEO) < 0)
1076 dvb_play_kernel(av7110, iframe_header, sizeof(iframe_header), 0, 1);
1079 dvb_play(av7110, buf, len, 0, 1);
1081 av7110_ipack_flush(&av7110->ipack[1]);
1084 return vidcom(av7110, AV_VIDEO_CMD_FREEZE, 1);
1094 struct av7110 *av7110 = dvbdev->priv;
1098 dprintk(1, "av7110:%p, cmd=%04x\n", av7110,cmd);
1109 av7110->videostate.play_state = VIDEO_STOPPED;
1110 if (av7110->videostate.stream_source == VIDEO_SOURCE_MEMORY)
1111 ret = av7110_av_stop(av7110, RP_VIDEO);
1113 ret = vidcom(av7110, AV_VIDEO_CMD_STOP,
1114 av7110->videostate.video_blank ? 0 : 1);
1116 av7110->trickmode = TRICK_NONE;
1120 av7110->trickmode = TRICK_NONE;
1121 if (av7110->videostate.play_state == VIDEO_FREEZED) {
1122 av7110->videostate.play_state = VIDEO_PLAYING;
1123 ret = vidcom(av7110, AV_VIDEO_CMD_PLAY, 0);
1127 if (av7110->videostate.stream_source == VIDEO_SOURCE_MEMORY) {
1128 if (av7110->playing == RP_AV) {
1129 ret = av7110_fw_cmd(av7110, COMTYPE_REC_PLAY, __Stop, 0);
1132 av7110->playing &= ~RP_VIDEO;
1134 ret = av7110_av_start_play(av7110, RP_VIDEO);
1137 ret = vidcom(av7110, AV_VIDEO_CMD_PLAY, 0);
1139 av7110->videostate.play_state = VIDEO_PLAYING;
1143 av7110->videostate.play_state = VIDEO_FREEZED;
1144 if (av7110->playing & RP_VIDEO)
1145 ret = av7110_fw_cmd(av7110, COMTYPE_REC_PLAY, __Pause, 0);
1147 ret = vidcom(av7110, AV_VIDEO_CMD_FREEZE, 1);
1149 av7110->trickmode = TRICK_FREEZE;
1153 if (av7110->playing & RP_VIDEO)
1154 ret = av7110_fw_cmd(av7110, COMTYPE_REC_PLAY, __Continue, 0);
1156 ret = vidcom(av7110, AV_VIDEO_CMD_PLAY, 0);
1158 av7110->videostate.play_state = VIDEO_PLAYING;
1159 av7110->trickmode = TRICK_NONE;
1164 av7110->videostate.stream_source = (video_stream_source_t) arg;
1168 av7110->videostate.video_blank = (int) arg;
1172 memcpy(parg, &av7110->videostate, sizeof(struct video_status));
1176 ret = dvb_video_get_event(av7110, parg, file->f_flags);
1180 memcpy(parg, &av7110->video_size, sizeof(video_size_t));
1188 av7110->display_panscan = VID_PAN_SCAN_PREF;
1191 av7110->display_panscan = VID_VC_AND_PS_PREF;
1194 av7110->display_panscan = VID_CENTRE_CUT_PREF;
1201 av7110->videostate.display_format = format;
1202 ret = av7110_fw_cmd(av7110, COMTYPE_ENCODER, SetPanScanType,
1203 1, av7110->display_panscan);
1212 av7110->display_ar = arg;
1213 ret = av7110_fw_cmd(av7110, COMTYPE_ENCODER, SetMonitorType,
1221 av7110->videostate.stream_source = VIDEO_SOURCE_MEMORY;
1222 dvb_ringbuffer_flush_spinlock_wakeup(&av7110->avout);
1223 ret = play_iframe(av7110, pic->iFrame, pic->size,
1230 if (av7110->playing & RP_VIDEO)
1231 ret = av7110_fw_cmd(av7110, COMTYPE_REC_PLAY,
1234 ret = vidcom(av7110, AV_VIDEO_CMD_FFWD, arg);
1236 av7110->trickmode = TRICK_FAST;
1237 av7110->videostate.play_state = VIDEO_PLAYING;
1242 if (av7110->playing&RP_VIDEO) {
1243 if (av7110->trickmode != TRICK_SLOW)
1244 ret = av7110_fw_cmd(av7110, COMTYPE_REC_PLAY, __Slow, 2, 0, 0);
1246 ret = vidcom(av7110, AV_VIDEO_CMD_SLOW, arg);
1248 ret = vidcom(av7110, AV_VIDEO_CMD_PLAY, 0);
1250 ret = vidcom(av7110, AV_VIDEO_CMD_STOP, 0);
1252 ret = vidcom(av7110, AV_VIDEO_CMD_SLOW, arg);
1255 av7110->trickmode = TRICK_SLOW;
1256 av7110->videostate.play_state = VIDEO_PLAYING;
1266 dvb_ringbuffer_flush_spinlock_wakeup(&av7110->avout);
1267 av7110_ipack_reset(&av7110->ipack[1]);
1268 if (av7110->playing == RP_AV) {
1269 ret = av7110_fw_cmd(av7110, COMTYPE_REC_PLAY,
1273 if (av7110->trickmode == TRICK_FAST)
1274 ret = av7110_fw_cmd(av7110, COMTYPE_REC_PLAY,
1276 if (av7110->trickmode == TRICK_SLOW) {
1277 ret = av7110_fw_cmd(av7110, COMTYPE_REC_PLAY,
1280 ret = vidcom(av7110, AV_VIDEO_CMD_SLOW, arg);
1282 if (av7110->trickmode == TRICK_FREEZE)
1283 ret = vidcom(av7110, AV_VIDEO_CMD_STOP, 1);
1302 struct av7110 *av7110 = dvbdev->priv;
1306 dprintk(1, "av7110:%p, cmd=%04x\n", av7110,cmd);
1314 if (av7110->audiostate.stream_source == AUDIO_SOURCE_MEMORY)
1315 ret = av7110_av_stop(av7110, RP_AUDIO);
1317 ret = audcom(av7110, AUDIO_CMD_MUTE);
1319 av7110->audiostate.play_state = AUDIO_STOPPED;
1323 if (av7110->audiostate.stream_source == AUDIO_SOURCE_MEMORY)
1324 ret = av7110_av_start_play(av7110, RP_AUDIO);
1326 ret = audcom(av7110, AUDIO_CMD_UNMUTE);
1328 av7110->audiostate.play_state = AUDIO_PLAYING;
1332 ret = audcom(av7110, AUDIO_CMD_MUTE);
1334 av7110->audiostate.play_state = AUDIO_PAUSED;
1338 if (av7110->audiostate.play_state == AUDIO_PAUSED) {
1339 av7110->audiostate.play_state = AUDIO_PLAYING;
1340 ret = audcom(av7110, AUDIO_CMD_UNMUTE | AUDIO_CMD_PCM16);
1345 av7110->audiostate.stream_source = (audio_stream_source_t) arg;
1350 ret = audcom(av7110, arg ? AUDIO_CMD_MUTE : AUDIO_CMD_UNMUTE);
1352 av7110->audiostate.mute_state = (int) arg;
1357 av7110->audiostate.AV_sync_state = (int) arg;
1358 ret = audcom(av7110, arg ? AUDIO_CMD_SYNC_ON : AUDIO_CMD_SYNC_OFF);
1362 if (FW_VERSION(av7110->arm_app) < 0x2621)
1364 av7110->audiostate.bypass_mode = (int)arg;
1368 av7110->audiostate.channel_select = (audio_channel_select_t) arg;
1369 switch(av7110->audiostate.channel_select) {
1371 ret = audcom(av7110, AUDIO_CMD_STEREO);
1373 if (av7110->adac_type == DVB_ADAC_CRYSTAL)
1374 i2c_writereg(av7110, 0x20, 0x02, 0x49);
1375 else if (av7110->adac_type == DVB_ADAC_MSP34x5)
1376 msp_writereg(av7110, MSP_WR_DSP, 0x0008, 0x0220);
1380 ret = audcom(av7110, AUDIO_CMD_MONO_L);
1382 if (av7110->adac_type == DVB_ADAC_CRYSTAL)
1383 i2c_writereg(av7110, 0x20, 0x02, 0x4a);
1384 else if (av7110->adac_type == DVB_ADAC_MSP34x5)
1385 msp_writereg(av7110, MSP_WR_DSP, 0x0008, 0x0200);
1389 ret = audcom(av7110, AUDIO_CMD_MONO_R);
1391 if (av7110->adac_type == DVB_ADAC_CRYSTAL)
1392 i2c_writereg(av7110, 0x20, 0x02, 0x45);
1393 else if (av7110->adac_type == DVB_ADAC_MSP34x5)
1394 msp_writereg(av7110, MSP_WR_DSP, 0x0008, 0x0210);
1404 memcpy(parg, &av7110->audiostate, sizeof(struct audio_status));
1408 if (FW_VERSION(av7110->arm_app) < 0x2621)
1416 dvb_ringbuffer_flush_spinlock_wakeup(&av7110->aout);
1417 av7110_ipack_reset(&av7110->ipack[0]);
1418 if (av7110->playing == RP_AV)
1419 ret = av7110_fw_cmd(av7110, COMTYPE_REC_PLAY,
1429 ret = av7110_set_volume(av7110, amix->volume_left, amix->volume_right);
1447 struct av7110 *av7110 = dvbdev->priv;
1450 dprintk(2, "av7110:%p, \n", av7110);
1456 dvb_ringbuffer_flush_spinlock_wakeup(&av7110->aout);
1457 dvb_ringbuffer_flush_spinlock_wakeup(&av7110->avout);
1458 av7110->video_blank = 1;
1459 av7110->audiostate.AV_sync_state = 1;
1460 av7110->videostate.stream_source = VIDEO_SOURCE_DEMUX;
1463 av7110->video_events.eventr = av7110->video_events.eventw = 0;
1472 struct av7110 *av7110 = dvbdev->priv;
1474 dprintk(2, "av7110:%p, \n", av7110);
1477 av7110_av_stop(av7110, RP_VIDEO);
1486 struct av7110 *av7110 = dvbdev->priv;
1489 dprintk(2, "av7110:%p, \n", av7110);
1493 dvb_ringbuffer_flush_spinlock_wakeup(&av7110->aout);
1494 av7110->audiostate.stream_source = AUDIO_SOURCE_DEMUX;
1501 struct av7110 *av7110 = dvbdev->priv;
1503 dprintk(2, "av7110:%p, \n", av7110);
1505 av7110_av_stop(av7110, RP_AUDIO);
1551 int av7110_av_register(struct av7110 *av7110)
1553 av7110->audiostate.AV_sync_state = 0;
1554 av7110->audiostate.mute_state = 0;
1555 av7110->audiostate.play_state = AUDIO_STOPPED;
1556 av7110->audiostate.stream_source = AUDIO_SOURCE_DEMUX;
1557 av7110->audiostate.channel_select = AUDIO_STEREO;
1558 av7110->audiostate.bypass_mode = 0;
1560 av7110->videostate.video_blank = 0;
1561 av7110->videostate.play_state = VIDEO_STOPPED;
1562 av7110->videostate.stream_source = VIDEO_SOURCE_DEMUX;
1563 av7110->videostate.video_format = VIDEO_FORMAT_4_3;
1564 av7110->videostate.display_format = VIDEO_LETTER_BOX;
1565 av7110->display_ar = VIDEO_FORMAT_4_3;
1566 av7110->display_panscan = VID_VC_AND_PS_PREF;
1568 init_waitqueue_head(&av7110->video_events.wait_queue);
1569 spin_lock_init(&av7110->video_events.lock);
1570 av7110->video_events.eventw = av7110->video_events.eventr = 0;
1571 av7110->video_events.overflow = 0;
1572 memset(&av7110->video_size, 0, sizeof (video_size_t));
1574 dvb_register_device(&av7110->dvb_adapter, &av7110->video_dev,
1575 &dvbdev_video, av7110, DVB_DEVICE_VIDEO);
1577 dvb_register_device(&av7110->dvb_adapter, &av7110->audio_dev,
1578 &dvbdev_audio, av7110, DVB_DEVICE_AUDIO);
1583 void av7110_av_unregister(struct av7110 *av7110)
1585 dvb_unregister_device(av7110->audio_dev);
1586 dvb_unregister_device(av7110->video_dev);
1589 int av7110_av_init(struct av7110 *av7110)
1595 struct ipack *ipack = av7110->ipack + i;
1603 ipack->data = av7110;
1606 dvb_ringbuffer_init(&av7110->avout, av7110->iobuf, AVOUTLEN);
1607 dvb_ringbuffer_init(&av7110->aout, av7110->iobuf + AVOUTLEN, AOUTLEN);
1609 av7110->kbuf[0] = (u8 *)(av7110->iobuf + AVOUTLEN + AOUTLEN + BMPLEN);
1610 av7110->kbuf[1] = av7110->kbuf[0] + 2 * IPACKS;
1615 void av7110_av_exit(struct av7110 *av7110)
1617 av7110_ipack_free(&av7110->ipack[0]);
1618 av7110_ipack_free(&av7110->ipack[1]);