Commit aa87371f authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

Linux DVB: migrate EN 50221 code

This needs testing (my DVB driver is not CI-capable).
parent 2b4266d1
......@@ -135,6 +135,11 @@ libdtv_plugin_la_DEPENDENCIES =
if HAVE_LINUX
libdtv_plugin_la_SOURCES += dtv/linux.c
if HAVE_DVBPSI
libdtv_plugin_la_SOURCES += dtv/en50221.c dtv/en50221.h
libdtv_plugin_la_CFLAGS += -DHAVE_DVBPSI $(DVBPSI_CFLAGS)
libdtv_plugin_la_LIBADD += $(DVBPSI_LIBS)
endif
libvlc_LTLIBRARIES += libdtv_plugin.la
endif
......
......@@ -43,6 +43,11 @@ const delsys_t *dvb_guess_system (dvb_device_t *);
float dvb_get_signal_strength (dvb_device_t *);
float dvb_get_snr (dvb_device_t *);
#ifdef HAVE_DVBPSI
struct dvbpsi_pmt_s;
void dvb_set_ca_pmt (dvb_device_t *, struct dvbpsi_pmt_s *);
#endif
int dvb_set_inversion (dvb_device_t *, int);
int dvb_tune (dvb_device_t *);
......
......@@ -50,13 +50,13 @@
# include <dvbpsi/demux.h>
# include <dvbpsi/sdt.h>
#undef ENABLE_HTTPD
#ifdef ENABLE_HTTPD
# include <vlc_httpd.h>
#endif
#include "dvb.h"
#include "../../demux/dvb-text.h"
#include "en50221.h"
#include "../demux/dvb-text.h"
#include "dtv/en50221.h"
typedef struct en50221_session_t
{
......
......@@ -24,10 +24,11 @@
*****************************************************************************/
typedef struct cam cam_t;
struct dvbpsi_pmt_s;
cam_t *en50221_Init( vlc_object_t *, int fd );
void en50221_Poll( cam_t * );
int en50221_SetCAPMT( cam_t *, dvbpsi_pmt_t * );
int en50221_SetCAPMT( cam_t *, struct dvbpsi_pmt_s * );
char *en50221_Status( cam_t *, char *req );
void en50221_End( cam_t * );
......
......@@ -37,6 +37,9 @@
#include <linux/dvb/dmx.h>
#include "dtv/dtv.h"
#ifdef HAVE_DVBPSI
# include "dtv/en50221.h"
#endif
#ifndef O_SEARCH
# define O_SEARCH O_RDONLY
......@@ -179,7 +182,9 @@ struct dvb_device
uint16_t pid;
} pids[MAX_PIDS];
#endif
int ca;
#ifdef HAVE_DVBPSI
cam_t *cam;
#endif
struct dvb_frontend_info info;
bool budget;
//size_t buffer_size;
......@@ -209,7 +214,9 @@ dvb_device_t *dvb_open (vlc_object_t *obj, bool tune)
d->obj = obj;
d->frontend = -1;
d->ca = -1;
#ifdef HAVE_DVBPSI
d->cam = NULL;
#endif
d->budget = var_InheritBool (obj, "dvb-budget-mode");
#ifndef USE_DMX
......@@ -290,10 +297,17 @@ dvb_device_t *dvb_open (vlc_object_t *obj, bool tune)
msg_Dbg (obj, " (%"PRIu32" tolerance)",
d->info.symbol_rate_tolerance);
d->ca = dvb_open_node (dirfd, device, "ca", O_RDWR);
if (d->ca == -1)
#ifdef HAVE_DVBPSI
int ca = dvb_open_node (dirfd, device, "ca", O_RDWR);
if (ca != -1)
{
d->cam = en50221_Init (obj, ca);
if (d->cam == NULL)
close (ca);
}
else
msg_Dbg (obj, "conditional access module not available (%m)");
#endif
}
close (dirfd);
return d;
......@@ -315,8 +329,10 @@ void dvb_close (dvb_device_t *d)
close (d->pids[i].fd);
}
#endif
if (d->ca != -1)
close (d->ca);
#ifdef HAVE_DVBPSI
if (d->cam != NULL)
en50221_End (d->cam);
#endif
if (d->frontend != -1)
close (d->frontend);
close (d->demux);
......@@ -332,6 +348,11 @@ ssize_t dvb_read (dvb_device_t *d, void *buf, size_t len)
struct pollfd ufd[2];
int n;
#ifdef HAVE_DVBPSI
if (d->cam != NULL)
en50221_Poll (d->cam);
#endif
ufd[0].fd = d->demux;
ufd[0].events = POLLIN;
if (d->frontend != -1)
......@@ -481,6 +502,14 @@ float dvb_get_snr (dvb_device_t *d)
return snr / 65535.;
}
#ifdef HAVE_DVBPSI
void dvb_set_ca_pmt (dvb_device_t *d, struct dvbpsi_pmt_s *pmt)
{
if (d->cam != NULL)
en50221_SetCAPMT (d->cam, pmt);
}
#endif
static int dvb_vset_props (dvb_device_t *d, size_t n, va_list ap)
{
struct dtv_property buf[n], *prop = buf;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment