diff options
author | 2004-01-29 10:36:33 +0000 | |
---|---|---|
committer | 2004-01-29 10:36:33 +0000 | |
commit | d578d8c865677b728fac6d9f5ebe750dd5b2e755 (patch) | |
tree | 6b7b49b74be3b93faa317146445bdc5e75cb500e /libmpdemux | |
parent | 294efef5fbac3b3a8b4e6d21f3d027ed2141308e (diff) |
Compliance with the DVB power management specification (doesn't close
the tuner after having tuned).
This permits to remove the parameter dvb_shutdown_timeout=0 to the
module dvb-core and ultimately
shuts down the card when the tuner isn't used.
patch by Nico <nsabbi@tiscali.it>
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@11873 b3059339-0415-0410-9bf9-f77b7e298cf2
Diffstat (limited to 'libmpdemux')
-rw-r--r-- | libmpdemux/dvb_tune.c | 70 | ||||
-rw-r--r-- | libmpdemux/dvbin.c | 43 | ||||
-rw-r--r-- | libmpdemux/dvbin.h | 2 |
3 files changed, 51 insertions, 64 deletions
diff --git a/libmpdemux/dvb_tune.c b/libmpdemux/dvb_tune.c index e1d7e4b5c2..46aee0a018 100644 --- a/libmpdemux/dvb_tune.c +++ b/libmpdemux/dvb_tune.c @@ -33,7 +33,7 @@ #ifdef HAVE_DVB_HEAD #include <linux/dvb/dmx.h> #include <linux/dvb/frontend.h> - static char* dvb_frontenddev[4]={"/dev/dvb/adapter0/frontend0","/dev/dvb/adapter1/frontend0","/dev/dvb/adapter2/frontend0","/dev/dvb/adapter3/frontend0"}; + char* dvb_frontenddev[4]={"/dev/dvb/adapter0/frontend0","/dev/dvb/adapter1/frontend0","/dev/dvb/adapter2/frontend0","/dev/dvb/adapter3/frontend0"}; char* dvb_dvrdev[4]={"/dev/dvb/adapter0/dvr0","/dev/dvb/adapter1/dvr0","/dev/dvb/adapter2/dvr0","/dev/dvb/adapter3/dvr0"}; char* dvb_demuxdev[4]={"/dev/dvb/adapter0/demux0","/dev/dvb/adapter1/demux0","/dev/dvb/adapter2/demux0","/dev/dvb/adapter3/demux0"}; static char* dvb_secdev[4]={"","","",""}; //UNUSED, ONLY FOR UNIFORMITY @@ -41,7 +41,7 @@ #include <ost/dmx.h> #include <ost/sec.h> #include <ost/frontend.h> - static char* dvb_frontenddev[4]={"/dev/ost/frontend0","/dev/ost/frontend1","/dev/ost/frontend2","/dev/ost/frontend3"}; + char* dvb_frontenddev[4]={"/dev/ost/frontend0","/dev/ost/frontend1","/dev/ost/frontend2","/dev/ost/frontend3"}; char* dvb_dvrdev[4]={"/dev/ost/dvr0","/dev/ost/dvr1","/dev/ost/dvr2","/dev/ost/dvr3"}; static char* dvb_secdev[4]={"/dev/ost/sec0","/dev/ost/sec1","/dev/ost/sec2","/dev/ost/sec3"}; char* dvb_demuxdev[4]={"/dev/ost/demux0","/dev/ost/demux1","/dev/ost/demux2","/dev/ost/demux3"}; @@ -60,22 +60,16 @@ int dvb_get_tuner_type(dvb_priv_t *priv) FrontendInfo fe_info; #endif - int res, fe_fd = -1; - - fe_fd = open(dvb_frontenddev[priv->card], O_RDWR); - if(fe_fd < 0) - { - mp_msg(MSGT_DEMUX, MSGL_ERR, "get_tuner_type(card %d), ERROR IN OPENING FRONTEND DEVICE %s: ERRNO %d\n", priv->card, dvb_frontenddev[priv->card], errno); - return 0; - } - + int res, fe_fd; + + fe_fd = priv->fe_fd; + res = ioctl(fe_fd, FE_GET_INFO, &fe_info); if(res < 0) { mp_msg(MSGT_DEMUX, MSGL_ERR, "FE_GET_INFO error: %d, FD: %d\n\n", errno, fe_fd); return 0; } - close(fe_fd); switch(fe_info.type) { @@ -86,20 +80,20 @@ int dvb_get_tuner_type(dvb_priv_t *priv) case FE_QPSK: mp_msg(MSGT_DEMUX, MSGL_INFO, "TUNER TYPE SEEMS TO BE DVB-S\n"); return TUNER_SAT; - + case FE_QAM: mp_msg(MSGT_DEMUX, MSGL_INFO, "TUNER TYPE SEEMS TO BE DVB-C\n"); return TUNER_CBL; - + default: mp_msg(MSGT_DEMUX, MSGL_ERR, "UNKNOWN TUNER TYPE\n"); - return 0; + return 0; } - -} + +} -static int open_fe(dvb_priv_t *priv) +int dvb_open_fe(dvb_priv_t *priv) { priv->fe_fd = open(dvb_frontenddev[priv->card], O_RDWR); if(priv->fe_fd < 0) @@ -201,29 +195,23 @@ dvb_tune(dvb_priv_t *priv, int freq, char pol, int srate, int diseqc, int tone, fe_spectral_inversion_t specInv, fe_modulation_t modulation, fe_guard_interval_t guardInterval, fe_transmit_mode_t TransmissionMode, fe_bandwidth_t bandWidth, fe_code_rate_t HP_CodeRate) { + int ris; + mp_msg(MSGT_DEMUX, MSGL_INFO, "dvb_tune Freq: %lu\n", freq); - if(! open_fe(priv)) - { - return 0; - } - + if(freq > 100000000) { - tune_it(priv->fe_fd, 0, freq, srate, 0, tone, specInv, diseqc, modulation, HP_CodeRate, TransmissionMode, guardInterval, bandWidth); + ris = tune_it(priv->fe_fd, 0, freq, srate, 0, tone, specInv, diseqc, modulation, HP_CodeRate, TransmissionMode, guardInterval, bandWidth); } else if(freq != 0) { - tune_it(priv->fe_fd, priv->sec_fd, freq, srate, pol, tone, specInv, diseqc, modulation, HP_CodeRate, TransmissionMode, guardInterval, bandWidth); + ris = tune_it(priv->fe_fd, priv->sec_fd, freq, srate, pol, tone, specInv, diseqc, modulation, HP_CodeRate, TransmissionMode, guardInterval, bandWidth); } - - close(priv->fe_fd); - -#ifdef HAVE_DVB_HEAD -#else - close(priv->sec_fd); -#endif - return 1; + if(ris != 0) + mp_msg(MSGT_DEMUX, MSGL_INFO, "dvb_tune, TUNING FAILED\n"); + + return (ris == 0); } @@ -670,7 +658,7 @@ static int tune_it(int fd_frontend, int fd_sec, unsigned int freq, unsigned int #ifdef HAVE_DVB_HEAD if (freq < 1000000) freq*=1000UL; feparams.frequency=freq; - feparams.inversion=INVERSION_OFF; + feparams.inversion=specInv; feparams.u.ofdm.bandwidth=bandwidth; feparams.u.ofdm.code_rate_HP=HP_CodeRate; feparams.u.ofdm.code_rate_LP=LP_CODERATE_DEFAULT; @@ -681,7 +669,7 @@ static int tune_it(int fd_frontend, int fd_sec, unsigned int freq, unsigned int #else if (freq < 1000000) freq*=1000UL; feparams.Frequency=freq; - feparams.Inversion=INVERSION_OFF; + feparams.Inversion=specInv; feparams.u.ofdm.bandWidth=bandwidth; feparams.u.ofdm.HP_CodeRate=HP_CodeRate; feparams.u.ofdm.LP_CodeRate=LP_CODERATE_DEFAULT; @@ -823,16 +811,16 @@ static int tune_it(int fd_frontend, int fd_sec, unsigned int freq, unsigned int mp_msg(MSGT_DEMUX, MSGL_V, "tuning DVB-C to %d, srate=%d\n",freq,srate); #ifdef HAVE_DVB_HEAD feparams.frequency=freq; - feparams.inversion=INVERSION_OFF; + feparams.inversion=specInv; feparams.u.qam.symbol_rate = srate; - feparams.u.qam.fec_inner = FEC_AUTO; - feparams.u.qam.modulation = QAM_64; + feparams.u.qam.fec_inner = HP_CodeRate; + feparams.u.qam.modulation = modulation; #else feparams.Frequency=freq; - feparams.Inversion=INVERSION_OFF; + feparams.Inversion=specInv; feparams.u.qam.SymbolRate = srate; - feparams.u.qam.FEC_inner = FEC_AUTO; - feparams.u.qam.QAM = QAM_64; + feparams.u.qam.FEC_inner = HP_CodeRate; + feparams.u.qam.QAM = modulation; #endif break; default: diff --git a/libmpdemux/dvbin.c b/libmpdemux/dvbin.c index 2e4903764f..80e2abdb79 100644 --- a/libmpdemux/dvbin.c +++ b/libmpdemux/dvbin.c @@ -113,7 +113,7 @@ extern int dvb_get_tuner_type(dvb_priv_t *priv); extern int dvb_tune(dvb_priv_t *priv, int freq, char pol, int srate, int diseqc, int tone, fe_spectral_inversion_t specInv, fe_modulation_t modulation, fe_guard_interval_t guardInterval, fe_transmit_mode_t TransmissionMode, fe_bandwidth_t bandWidth, fe_code_rate_t HP_CodeRate); -extern char *dvb_dvrdev[4], *dvb_demuxdev[4]; +extern char *dvb_dvrdev[4], *dvb_demuxdev[4], *dvb_frontenddev[4]; dvb_channels_list *dvb_list_ptr = NULL; @@ -348,15 +348,14 @@ static int reset_demuxers(dvb_priv_t *priv) } if(channel->vpid) - if(! dvb_set_ts_filt(priv->demux_fd[0], channel->vpid, DMX_PES_VIDEO)) + if(! dvb_set_ts_filt(priv->demux_fd[0], channel->vpid, DMX_PES_OTHER)) return 0; - //dvb_demux_start(priv->demux_fd[0]); if(channel->apid1) - if(! dvb_set_ts_filt(priv->demux_fd[1], channel->apid1, DMX_PES_AUDIO)) + if(! dvb_set_ts_filt(priv->demux_fd[1], channel->apid1, DMX_PES_OTHER)) return 0; - printf("RESET DEMUXERS SUCCEDED, errno=%d\n\n\n", errno); + return 1; } @@ -440,14 +439,12 @@ int dvb_set_channel(dvb_priv_t *priv, int n) //sets demux filters and restart the stream if(channel->vpid) - if(! dvb_set_ts_filt(priv->demux_fd[0], channel->vpid, DMX_PES_VIDEO)) + if(! dvb_set_ts_filt(priv->demux_fd[0], channel->vpid, DMX_PES_OTHER)) return 0; - //dvb_demux_start(priv->demux_fd[0]); if(channel->apid1) - if(! dvb_set_ts_filt(priv->demux_fd[1], channel->apid1, DMX_PES_AUDIO)) + if(! dvb_set_ts_filt(priv->demux_fd[1], channel->apid1, DMX_PES_OTHER)) return 0; - //dvb_demux_start(priv->demux_fd[1]); return 1; } @@ -505,6 +502,12 @@ static void dvbin_close(stream_t *stream) close(priv->dvr_fd); close(priv->demux_fd[0]); close(priv->demux_fd[1]); + + close(priv->fe_fd); +#ifdef HAVE_DVB + close(priv->sec_fd); +#endif + priv->is_on = 0; priv->stream = NULL; if(dvb_list_ptr) @@ -572,7 +575,7 @@ static int dvb_streaming_start(dvb_priv_t *priv, struct stream_priv_s *opts, int { pids[npids] = channel->vpid; } - pestypes[npids] = DMX_PES_VIDEO; + pestypes[npids] = DMX_PES_OTHER; npids++; if(opts->aid > 0) @@ -583,7 +586,7 @@ static int dvb_streaming_start(dvb_priv_t *priv, struct stream_priv_s *opts, int { pids[npids] = channel->apid1; } - pestypes[npids] = DMX_PES_AUDIO; + pestypes[npids] = DMX_PES_OTHER; npids++; @@ -634,12 +637,11 @@ static int dvb_open(stream_t *stream, int mode, void *opts, int *file_format) // I don't force the file format bacause, although it's almost always TS, // there are some providers that stream an IP multicast with M$ Mpeg4 inside struct stream_priv_s* p = (struct stream_priv_s*)opts; - char *name = NULL, *filename; + char *filename; dvb_priv_t *priv; int tuner_type = 0; - if(mode != STREAM_READ) return STREAM_UNSUPORTED; @@ -650,16 +652,13 @@ static int dvb_open(stream_t *stream, int mode, void *opts, int *file_format) priv = (dvb_priv_t *)stream->priv; priv->stream = stream; - name = malloc(sizeof(char)*128); - - if(name == NULL) - { - mp_msg(MSGT_DEMUX, MSGL_ERR, "COULDN'T MALLOC SOME TMP MEMORY, EXIT!\n"); - return STREAM_ERROR; - } - priv->card = p->card - 1; - + if(! dvb_open_fe(priv)) + { + mp_msg(MSGT_DEMUX, MSGL_ERR, "ERROR OPENING FRONTEND DEVICE %s: %d\n", dvb_frontenddev[priv->card], errno); + return STREAM_ERROR; + } + if(!strncmp(p->type, "CBL", 3)) { tuner_type = TUNER_CBL; diff --git a/libmpdemux/dvbin.h b/libmpdemux/dvbin.h index ed731df70c..63cad2a152 100644 --- a/libmpdemux/dvbin.h +++ b/libmpdemux/dvbin.h @@ -81,8 +81,8 @@ typedef struct { extern int dvb_step_channel(dvb_priv_t *, int); extern int dvb_set_channel(dvb_priv_t *, int); +extern int dvb_open_fe(dvb_priv_t *priv); -extern dvb_channels_list *dvb_get_channels(char *, int); extern dvb_history_t dvb_prev_next; |