diff options
Diffstat (limited to 'test')
| -rw-r--r-- | test/Makefile | 6 | ||||
| -rw-r--r-- | test/README | 2 | ||||
| -rw-r--r-- | test/lock_s.c | 531 | ||||
| -rw-r--r-- | test/test_tapdmx.c | 160 | ||||
| -rw-r--r-- | test/test_video.c | 53 | ||||
| -rw-r--r-- | test/video.c | 182 | 
6 files changed, 722 insertions, 212 deletions
| diff --git a/test/Makefile b/test/Makefile index 30cb9e3..4407d02 100644 --- a/test/Makefile +++ b/test/Makefile @@ -10,6 +10,7 @@ binaries = diseqc          \             test_av         \             test_av_play    \             test_dvr        \ +           test_tapdmx     \             test_dvr_play   \             test_pes        \             test_sec_ne     \ @@ -18,9 +19,10 @@ binaries = diseqc          \             test_stillimage \             test_tt         \             test_vevent     \ +           test_video      \  	   evtest	   \ -	   video	   \ -	   szap2 +	   szap2           \ +	   lock_s  .PHONY: all diff --git a/test/README b/test/README index 2b39936..213ba71 100644 --- a/test/README +++ b/test/README @@ -47,4 +47,4 @@ test_dmx	:  test_dvr	:  test_front	:  test_switch	: -test_video	: +test_video	: Play video-only file on /dev/dvb/adapter0/video0 diff --git a/test/lock_s.c b/test/lock_s.c new file mode 100644 index 0000000..7bbab59 --- /dev/null +++ b/test/lock_s.c @@ -0,0 +1,531 @@ +/* + * lock_s - Ultra simple DVB-S lock test application + * A minimal lock test application derived from szap.c + * for testing purposes + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#include <stdio.h> +#include <stdlib.h> +#include <limits.h> +#include <string.h> +#include <errno.h> +#include <sys/ioctl.h> +#include <sys/types.h> +#include <sys/stat.h> +#include <sys/poll.h> +#include <sys/param.h> +#include <fcntl.h> +#include <time.h> +#include <unistd.h> +#include <ctype.h> + +#include <stdint.h> +#include <sys/time.h> + +#include <linux/dvb/frontend.h> + +#define FEDEVICE		"/dev/dvb/adapter%d/frontend%d" + +static char *usage_str = "\n lock_s ver:0.0.1: Simple utility to test DVB-S signal lock.\n" +			 "     \n" +			 "     usage: lock_s [[PARAMS] [OPTIONS]]\n" +			 "       dvbstune [params] tune to user provided DVB-S parameters\n" +			 "     -a number : use given adapter (default 0)\n" +			 "     -f number : use given frontend (default 0)\n" +			 "     -p params : parameters to be used for tuning\n" +			 "	frequency (Mhz) Polarization (v/h) Symbol rate (MSPS)\n" +			 "      \n" +			 "     -s pos    : DiSEqC switch position\n" +			 "     -H        : human readable output\n" +			 "     -l lnb-type (DVB-S Only) (use -l help to print types) or \n" +			 "     -l low[,high[,switch]] in Mhz\n"; + +static char *univ_desc[] = { +	"Europe", +	"10800 to 11800 MHz and 11600 to 12700 Mhz", +	"Dual LO, loband 9750, hiband 10600 MHz", +	(char *)NULL +}; + +static char *dbs_desc[] = { +	"Expressvu, North America", +	"12200 to 12700 MHz", +	"Single LO, 11250 MHz", +	(char *)NULL +}; + +static char *standard_desc[] = { +	"10945 to 11450 Mhz", +	"Single LO, 10000 Mhz", +	(char *)NULL +}; + +static char *enhan_desc[] = { +	"Astra", +	"10700 to 11700 MHz", +	"Single LO, 9750 MHz", +	(char *)NULL +}; + +static char *cband_desc[] = { +	"Big Dish", +	"3700 to 4200 MHz", +	"Single LO, 5150 Mhz", +	(char *)NULL +}; + +enum sec_bands { +	SEC_LO_BAND	= 0, +	SEC_HI_BAND	= 1, +}; + +struct sec_params { +	unsigned int		freq; +	enum fe_sec_voltage	voltage; +	unsigned int		srate; + +	unsigned int		freq_if; +	int			pos; /* DiSEqC sw. pos */ + +	fe_sec_tone_mode_t	tone; +	fe_sec_mini_cmd_t	burst; +}; + +struct lnb_types_st { +	char	*name; +	char	**desc; +	unsigned long	low_val; +	unsigned long	high_val;	/* zero indicates no hiband */ +	unsigned long	switch_val;	/* zero indicates no hiband */ +} lnbs[] = { +	{"UNIVERSAL",	univ_desc,	9750,  10600, 11700 }, + 	{"DBS",		dbs_desc, 	11250, 0,     0     }, +	{"STANDARD",	standard_desc,	10000, 0,     0     }, +	{"ENHANCED",	enhan_desc,	9750,  0,     0     }, +	{"C-BAND",	cband_desc,	5150,  0,     0     }, +}; + +struct diseqc_cmd { +	struct dvb_diseqc_master_cmd cmd; +	uint32_t wait; +}; + +int lnb_parse(char *str, struct lnb_types_st *lnbp) +{ +	int i; +	char *cp, *np; + +	memset(lnbp, 0, sizeof (*lnbp)); +	cp = str; +	while (*cp && isspace(*cp)) +		cp++; + +	if (isalpha(*cp)) { +		for (i = 0; i < (int)(sizeof(lnbs) / sizeof(lnbs[0])); i++) { +			if (!strcasecmp(lnbs[i].name, cp)) { +				*lnbp = lnbs[i]; +				return 1; +			} +		} +		return -1; +	} + +	if (*cp == '\0' || !isdigit(*cp)) +		return -1; +	lnbp->low_val = strtoul(cp, &np, 0); +	if (lnbp->low_val == 0) +		return -1; + +	cp = np; +	while(*cp && (isspace(*cp) || *cp == ',')) +		cp++; +	if (*cp == '\0') +		return 1; +	if (!isdigit(*cp)) +		return -1; +	lnbp->high_val = strtoul(cp, &np, 0); + +	cp = np; +	while(*cp && (isspace(*cp) || *cp == ',')) +		cp++; +	if (*cp == '\0') +		return 1; +	if (!isdigit(*cp)) +		return -1; +	lnbp->switch_val = strtoul(cp, NULL, 0); +	return 1; +} + +int params_decode(char *str, char **argv, struct sec_params *params) +{ +	unsigned int freq; +	char *pol; +	char *cp, *np; + +	cp = str; + +	while (*cp && isspace(*cp)) +		cp++; + +	/* get frequency */ +	if (*cp == '\0' || !isdigit(*cp)) +		return -1; +	freq = strtoul(cp, &np, 0); +	params->freq = freq; +	if (freq == 0) +		return -1; + +	/* polarization v=13v:0, h=18v:0 */ +	pol = argv[optind]; /* v/h */ +	(!strncmp(pol, "v", 1)) ? (params->voltage = 0) : (params->voltage = 1); +	params->srate = strtoul(argv[optind + 1], NULL, 0); + +	return 1; +} + +/** + * lnb_setup(struct lnb_types_st *lnb, unsigned int freq, unsigned int *freq_if) + * @lnb		: lnb type as described int lnb_types_st + * @freq	: transponder frequency which user requests + * @freq_if	: resultant Intermediate Frequency after down conversion + */ +static int lnb_setup(struct lnb_types_st *lnb, struct sec_params *params) +{ +	int ret = 0; + +	if (!lnb) { +		fprintf(stderr, "Error: lnb_types=NULL\n"); +		ret = -EINVAL; +		goto err; +	} + +	/* TODO! check upper and lower limits from LNB types */ +	if (!params->freq) { +		fprintf(stderr, "Error: invalid frequency, f:%d", params->freq); +		ret = -EINVAL; +		goto err; +	} + +	if (lnb->switch_val && lnb->high_val && params->freq >= lnb->switch_val) { +		/* HI Band */ +		params->freq_if	= params->freq - lnb->high_val; +		params->tone	= SEC_TONE_ON; +	} else { +		/* LO Band */ +		params->tone	= SEC_TONE_OFF; +		if (params->freq < lnb->low_val) +			params->freq_if = lnb->low_val - params->freq; +		else +			params->freq_if = params->freq - lnb->low_val; + +	} +err: +	return ret; +} + +static int diseqc_send_msg(int fd, struct sec_params *params, struct diseqc_cmd *cmd) +{ +	int ret = 0; + +	ret = ioctl(fd, FE_SET_TONE, SEC_TONE_OFF); +	if (ret < 0) { +		fprintf(stderr, "FE_SET_TONE failed\n"); +		goto err; +	} + +	ret = ioctl(fd, FE_SET_VOLTAGE, params->voltage); +	if (ret < 0) { +		fprintf(stderr, "FE_SET_VOLTAGE failed, voltage=%d\n", params->voltage); +		usleep(15 * 1000); +		goto err; +	} + +	ret = ioctl(fd, FE_DISEQC_SEND_MASTER_CMD, &cmd->cmd); +	if (ret < 0) { +		perror("FE_DISEQC_SEND_MASTER_CMD failed"); +		usleep(cmd->wait * 1000); +		usleep(15 * 1000); +		goto err; +	} + +	ret = ioctl(fd, FE_DISEQC_SEND_BURST, params->burst); +	if (ret < 0) { +		fprintf(stderr, "FE_DISEQC_SEND_BURST failed, burst=%d\n", params->burst); +		usleep(15 * 1000); +		goto err; +	} + +	ret = ioctl(fd, FE_SET_TONE, params->tone); +	if (ret < 0) { +		fprintf(stderr, "FE_SET_TONE failed, tone=%d\n", params->tone); +		goto err; +	} +err: +	return ret; +} + +static int diseqc_setup(int fd, struct sec_params *params) +{ +	int pos				= params->pos; +	int band			= params->tone; +	fe_sec_voltage_t voltage	= params->voltage; +	int ret; + +	struct diseqc_cmd cmd = {{{0xe0, 0x10, 0x38, 0xf0, 0x00, 0x00}, 4}, 0 }; + +	/* +	 * param: high nibble: reset bits, low nibble set bits, +	 * bits are: option, position, polarization, band +	 */ +	cmd.cmd.msg[3] =	 0xf0			| +				(((pos * 4) & 0x0f)	| +				(band ? 1 : 0)		| +				(voltage ? 0 : 2)); + +	ret = diseqc_send_msg(fd, params, &cmd); +	if (ret < 0) { +		fprintf(stderr, "SEC message send failed, err=%d", ret); +		return -EIO; +	} +	return 0; +} + +static int tune_to(int fd, struct sec_params *sec) +{ +	struct dvb_frontend_parameters params; +	struct dvb_frontend_event ev; +	int ret; + +	/* discard stale QPSK events */ +	while (1) { +		ret = ioctl(fd, FE_GET_EVENT, &ev); +		if (ret == -1) +			break; +	} + +	params.frequency		= sec->freq_if; +	params.inversion		= INVERSION_AUTO; +	params.u.qpsk.symbol_rate	= sec->srate; +	params.u.qpsk.fec_inner		= FEC_AUTO; + +	ret = ioctl(fd, FE_SET_FRONTEND, ¶ms); +	if (ret == -1) { +		fprintf(stderr, "FE_SET_FRONTEND error=%d\n", ret); +		return -1; +	} + +	return 0; +} + +static int frontend_open(int *fd, int adapter, int frontend) +{ +	static struct dvb_frontend_info info; +	char fedev[128]; +	int ret = 0; + +	snprintf(fedev, sizeof(fedev), FEDEVICE, adapter, frontend); +	*fd = open(fedev, O_RDWR | O_NONBLOCK); +	if (*fd < 0) { +		fprintf(stderr, "Frontend %d open failed\n", frontend); +		ret = -1; +		goto err; +	} + +	ret = ioctl(*fd, FE_GET_INFO, &info); +	if (ret < 0) { +		fprintf(stderr, "ioctl FE_GET_INFO failed\n"); +		goto err; +	} + +	if (info.type != FE_QPSK) { +		fprintf(stderr, "frontend device is not a QPSK (DVB-S) device!\n"); +		ret = -ENODEV; +		goto err; +	} +	return 0; +err: +	fprintf(stderr, "Closing Adapter:%d Frontend:%d\n", adapter, frontend); +	close(*fd); +	return ret; +} + +void bad_usage(char *pname, int prlnb) +{ +	int i; +	struct lnb_types_st *lnb; +	char **cp; + +	if (!prlnb) { +		fprintf (stderr, usage_str, pname); +	} else { +		i = 0; +		fprintf(stderr, "-l <lnb-type> or -l low[,high[,switch]] in Mhz\nwhere <lnb-type> is:\n"); +		while ((lnb = &lnbs[i]) != NULL) { +			fprintf (stderr, "%s\n", lnb->name); +			for (cp = lnb->desc; *cp; cp++) +				fprintf (stderr, "   %s\n", *cp); +			i++; +		} +	} +} + +static int check_frontend (int fd, int human_readable) +{ +	fe_status_t status; +	uint16_t snr, signal; +	uint32_t ber, uncorrected_blocks; +	int ret; + +	do { +		ret = ioctl(fd, FE_READ_STATUS, &status); +		if (ret == -1) { +			fprintf(stderr, "FE_READ_STATUS failed, err=%d", ret); +			return -EIO; +		} + +		/* +		 * some frontends might not support all these ioctls, thus we +		 * avoid printing errors +		 */ +		ret = ioctl(fd, FE_READ_SIGNAL_STRENGTH, &signal); +		if (ret == -1) +			signal = -2; + +		ret = ioctl(fd, FE_READ_SNR, &snr); +		if (ret == -1) +			snr = -2; + +		ret = ioctl(fd, FE_READ_BER, &ber); +		if (ret == -1) +			ber = -2; + +		ret = ioctl(fd, FE_READ_UNCORRECTED_BLOCKS, &uncorrected_blocks); +		if (ret == -1) +			uncorrected_blocks = -2; + +		if (human_readable) { +			printf ("status %02x | signal %3u%% | snr %3u%% | ber %d | unc %d | ", +				status, (signal * 100) / 0xffff, (snr * 100) / 0xffff, ber, uncorrected_blocks); +		} else { +			printf ("status %02x | signal %04x | snr %04x | ber %08x | unc %08x | ", +				status, signal, snr, ber, uncorrected_blocks); +		} + +		if (status & FE_HAS_LOCK) +			printf("FE_HAS_LOCK"); + +		printf("\n"); +		usleep(1000000); +	} while (1); + +	return 0; +} + + +/** + * basic options needed + * @adapter + * @frontend + * @freq (Mhz) + * @pol (13/18) + * @srate (kSps) + * @pos (0 - 3) + * @LNB (low, high, switch) Mhz + * + */ +int main(int argc, char *argv[]) +{ +	int opt; +	int ret, fd, adapter=0, frontend=0, pos; +	int simple; +	struct lnb_types_st lnb; +	struct sec_params sec; + +	lnb = lnbs[0]; /* default is Universal LNB */ +	while ((opt = getopt(argc, argv, "Hh:a:f:p:s:l:")) != -1) { +		switch (opt) { +		case '?': +		case 'h': +		default: /* help */ +			bad_usage(argv[0], 0); +			break; +		case 'a': /* adapter */ +			adapter = strtoul(optarg, NULL, 0); +			break; +		case 'f': /* demodulator (device) */ +			frontend = strtoul(optarg, NULL, 0); +			break; +		case 'p': /* parameters */ +			if (params_decode(optarg, argv, &sec) < 0) { +				bad_usage(argv[0], 1); +				return -1; +			} +			break; +		case 's': /* diseqc position */ +			pos = strtoul(optarg, NULL, 0); +			pos % 2 ? (sec.burst = SEC_MINI_B) : (sec.burst = SEC_MINI_A); +			break; +		case 'l': +			if (lnb_parse(optarg, &lnb) < 0) { +				bad_usage(argv[0], 1); +				return -1; +			} +			break; +		case 'H': +			simple = 1; /* human readable */ +			break; +		} +	} +	lnb.low_val	*= 1000; /* kHz */ +	lnb.high_val	*= 1000; /* kHz */ +	lnb.switch_val	*= 1000; /* kHz */ + +	sec.freq *= 1000; /* kHz */ +	sec.srate *= 1000; + +	ret = frontend_open(&fd, adapter, frontend); +	if (ret < 0) { +		fprintf(stderr, "Adapter:%d Frontend:%d open failed, err=%d\n", adapter, frontend, ret); +		return -1; +	} +	ret = lnb_setup(&lnb, &sec); +	if (ret < 0) { +		fprintf(stderr, "LNB setup failed, err=%d\n", ret); +		fprintf(stderr, "%s", usage_str); +		goto err; +	} + +	ret = diseqc_setup(fd, &sec); +	if (ret < 0) { +		fprintf(stderr, "SEC setup failed, err=%d\n", ret); +		goto err;; +	} + +	ret = tune_to(fd, &sec); +	if (ret < 0) { +		fprintf(stderr, "Adapter:%d Frontend:%d tune_to %d %d failed, err=%d\n", adapter, frontend, sec.freq, sec.srate, ret); +		goto err;; +	} + +	ret = check_frontend(fd, 1); +	if (ret < 0) { +		fprintf(stderr, "check frontend failed\n"); +		goto err;; +	} +err: +	return ret; +} diff --git a/test/test_tapdmx.c b/test/test_tapdmx.c new file mode 100644 index 0000000..09bd0dc --- /dev/null +++ b/test/test_tapdmx.c @@ -0,0 +1,160 @@ +/* test_tapdmx.c - Test recording a TS from the dmx device. + * very similar to test_dvr but using the new DMX_OUT_TSDEMUX_TAP + * usage: test_tapdmx PID [more PIDs...] + * + * test_dvr is + *   Copyright (C) 2003 convergence GmbH + *   Johannes Stezenbach <js@convergence.de> + * test_tapdmx conversion is + *   Copyright (C) 2011 B1 Systems GmbH + *   Stefan Seyfried <seife+dvb@b1-systems.com> + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * as published by the Free Software Foundation; either version 2.1 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +//hm, I haven't tested writing large files yet... maybe it works +#define _LARGEFILE64_SOURCE + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <unistd.h> +#include <sys/types.h> +#include <sys/stat.h> +#include <fcntl.h> +#include <sys/ioctl.h> +#include <errno.h> +#include <inttypes.h> + +#include <linux/dvb/dmx.h> + +static unsigned long BUF_SIZE = 64 * 1024; +static unsigned long long total_bytes; + +static void usage(void) +{ +	fprintf(stderr, "usage: test_tapdmx file PID [more PIDs...]\n" +			"       record a partial TS stream consisting of TS packets\n" +			"       with the selected PIDs to the given file.\n" +			"       Use PID 0x2000 to record the full TS stream (if\n" +			"       the hardware supports it).\n" +			"       The demux device used can be changed by setting\n" +			"       the environment variable DEMUX.\n" +			"       You can override the input buffer size by setting BUF_SIZE to\n" +			"       the number of bytes wanted.\n" +			"       Note: There is no output buffering, so writing to stdout is\n" +			"       not really supported, but you can try something like:\n" +			"       BUF_SIZE=188 ./test_tapdmx /dev/stdout 0 2>/dev/null | xxd\n" +			"       ./test_tapdmx /dev/stdout 0x100 0x110 2>/dev/null| xine stdin://mpeg2\n" +			"\n"); +	exit(1); +} + + +static void process_data(int dvrfd, int tsfd) +{ +	uint8_t buf[BUF_SIZE]; +	int bytes, b2; + +	bytes = read(dvrfd, buf, sizeof(buf)); +	if (bytes < 0) { +		perror("read"); +		if (errno == EOVERFLOW) +			return; +		fprintf(stderr, "exiting due to read() error\n"); +		exit(1); +	} +	total_bytes += bytes; +	b2 = write(tsfd, buf, bytes); +	if (b2 == -1) { +		perror("write"); +		exit(1); +	} else if (b2 < bytes) +		fprintf(stderr, "warning: read %d, but wrote only %d bytes\n", bytes, b2); +	else +		fprintf(stderr, "got %d bytes (%llu total)\n", bytes, total_bytes); +} + +int main(int argc, char *argv[]) +{ +	int dmxfd, tsfd; +	unsigned int pid; +	struct dmx_pes_filter_params f; +	char *dmxdev = "/dev/dvb/adapter0/demux0"; +	int i; +	char *chkp; + +	if (argc < 3) +		usage(); + +	if (getenv("DEMUX")) +		dmxdev = getenv("DEMUX"); + +	fprintf(stderr, "using '%s'\n" +		"writing to '%s'\n", dmxdev, argv[1]); +	tsfd = open(argv[1], O_WRONLY | O_CREAT | O_TRUNC | O_LARGEFILE, 0664); +	if (tsfd == -1) { +		perror("cannot write output file"); +		return 1; +	} + +	dmxfd = open(dmxdev, O_RDONLY); +	if (dmxfd == -1) { +		perror("cannot open dmx device"); +		return 1; +	} + +	if (getenv("BUF_SIZE") && ((BUF_SIZE = strtoul(getenv("BUF_SIZE"), NULL, 0)) > 0)) +		fprintf(stderr, "BUF_SIZE = %lu\n", BUF_SIZE); + +	pid = strtoul(argv[2], &chkp, 0); +	if (pid > 0x2000 || chkp == argv[2]) +		usage(); +	fprintf(stderr, "adding filter for PID 0x%04x\n", pid); + +	memset(&f, 0, sizeof(f)); +	f.pid = (uint16_t) pid; +	f.input = DMX_IN_FRONTEND; +	f.output = DMX_OUT_TSDEMUX_TAP; +	f.pes_type = DMX_PES_OTHER; + +	if (ioctl(dmxfd, DMX_SET_PES_FILTER, &f) == -1) { +		perror("DMX_SET_PES_FILTER"); +		return 1; +	} + +	for (i = 3; i < argc; i++) { +		pid = strtoul(argv[i], &chkp, 0); +		if (pid > 0x2000 || chkp == argv[i]) +			usage(); +		fprintf(stderr, "adding filter for PID 0x%04x\n", pid); +		if (ioctl(dmxfd, DMX_ADD_PID, &pid) == -1) { +			perror("DMX_ADD_PID"); +			return 1; +		} +	} +	if (ioctl(dmxfd, DMX_START) == -1) { +		perror("DMX_START"); +		close(dmxfd); +		return 1; +	} + +	for (;;) { +		process_data(dmxfd, tsfd); +	} + +	close(dmxfd); +	return 0; +} diff --git a/test/test_video.c b/test/test_video.c index ac66050..fe2f440 100644 --- a/test/test_video.c +++ b/test/test_video.c @@ -23,6 +23,7 @@  #include <sys/ioctl.h>  #include <stdio.h> +#include <stdlib.h>  #include <stdint.h>  #include <sys/types.h>  #include <sys/stat.h> @@ -31,8 +32,7 @@  #include <unistd.h>  #include <linux/dvb/dmx.h> -#include <linux/dvb/frontend_old.h> -#include <linux/dvb/sec.h> +#include <linux/dvb/frontend.h>  #include <linux/dvb/video.h>  #include <sys/poll.h> @@ -100,7 +100,7 @@ int videoSelectSource(int fd, video_stream_source_t source) -int videoSetBlank(int fd, boolean state) +int videoSetBlank(int fd, int state)  {  	int ans; @@ -138,72 +138,72 @@ int videoSlowMotion(int fd,int nframes)  int videoGetStatus(int fd)  { -	struct video_status stat; +	struct video_status vstat;  	int ans; -	if ((ans = ioctl(fd,VIDEO_GET_STATUS, &stat)) < 0) { +	if ((ans = ioctl(fd,VIDEO_GET_STATUS, &vstat)) < 0) {  		perror("VIDEO GET STATUS: ");  		return -1;  	}  	printf("Video Status:\n");  	printf("  Blank State          : %s\n", -	       (stat.video_blank ? "BLANK" : "STILL")); +	       (vstat.video_blank ? "BLANK" : "STILL"));  	printf("  Play State           : "); -	switch ((int)stat.play_state){ +	switch ((int)vstat.play_state){  	case VIDEO_STOPPED: -		printf("STOPPED (%d)\n",stat.play_state); +		printf("STOPPED (%d)\n",vstat.play_state);  		break;  	case VIDEO_PLAYING: -		printf("PLAYING (%d)\n",stat.play_state); +		printf("PLAYING (%d)\n",vstat.play_state);  		break;  	case VIDEO_FREEZED: -		printf("FREEZED (%d)\n",stat.play_state); +		printf("FREEZED (%d)\n",vstat.play_state);  		break;  	default: -		printf("unknown (%d)\n",stat.play_state); +		printf("unknown (%d)\n",vstat.play_state);  		break;  	}  	printf("  Stream Source        : "); -	switch((int)stat.stream_source){ +	switch((int)vstat.stream_source){  	case VIDEO_SOURCE_DEMUX: -		printf("DEMUX (%d)\n",stat.stream_source); +		printf("DEMUX (%d)\n",vstat.stream_source);  		break;  	case VIDEO_SOURCE_MEMORY: -		printf("MEMORY (%d)\n",stat.stream_source); +		printf("MEMORY (%d)\n",vstat.stream_source);  		break;  	default: -		printf("unknown (%d)\n",stat.stream_source); +		printf("unknown (%d)\n",vstat.stream_source);  		break;  	}  	printf("  Format (Aspect Ratio): "); -	switch((int)stat.video_format){ +	switch((int)vstat.video_format){  	case VIDEO_FORMAT_4_3: -		printf("4:3 (%d)\n",stat.video_format); +		printf("4:3 (%d)\n",vstat.video_format);  		break;  	case VIDEO_FORMAT_16_9: -		printf("16:9 (%d)\n",stat.video_format); +		printf("16:9 (%d)\n",vstat.video_format);  		break;  	default: -		printf("unknown (%d)\n",stat.video_format); +		printf("unknown (%d)\n",vstat.video_format);  		break;  	}  	printf("  Display Format       : "); -	switch((int)stat.display_format){ +	switch((int)vstat.display_format){  	case VIDEO_PAN_SCAN: -		printf("Pan&Scan (%d)\n",stat.display_format); +		printf("Pan&Scan (%d)\n",vstat.display_format);  		break;  	case VIDEO_LETTER_BOX: -		printf("Letterbox (%d)\n",stat.display_format); +		printf("Letterbox (%d)\n",vstat.display_format);  		break;  	case VIDEO_CENTER_CUT_OUT: -		printf("Center cutout (%d)\n",stat.display_format); +		printf("Center cutout (%d)\n",vstat.display_format);  		break;  	default: -		printf("unknown (%d)\n",stat.display_format); +		printf("unknown (%d)\n",vstat.display_format);  		break;  	}  	return 0; @@ -230,7 +230,6 @@ void play_file_video(int filefd, int fd)  	int written;  	struct pollfd pfd[NFD];  	int stopped = 0; -	int ch;  	pfd[0].fd = STDIN_FILENO;  	pfd[0].events = POLLIN; @@ -327,7 +326,7 @@ void load_iframe(int filefd, int fd)  	videoPlay(fd);  } -main(int argc, char **argv) +int main(int argc, char **argv)  {  	int fd;  	int filefd; @@ -338,7 +337,7 @@ main(int argc, char **argv)  		perror("File open:");  		return -1;  	} -	if ((fd = open("/dev/ost/video1",O_RDWR|O_NONBLOCK)) < 0){ +	if ((fd = open("/dev/dvb/adapter0/video0",O_RDWR|O_NONBLOCK)) < 0){  		perror("VIDEO DEVICE: ");  		return -1;  	} diff --git a/test/video.c b/test/video.c deleted file mode 100644 index fae421e..0000000 --- a/test/video.c +++ /dev/null @@ -1,182 +0,0 @@ -#define USAGE \ -"\n" \ -"\n A tiny video watching application, just starts capturing /dev/video" \ -"\n into /dev/fb0." \ -"\n Be shure to have >8Bit/pixel color resolution and r/w access for " \ -"\n /dev/video0, /dev/fb0 and /dev/tty0 to let this work..." \ -"\n" \ -"\n  compile with" \ -"\n" \ -"\n  $ gcc -g -Wall -O2 -o video video.c -I../../ost/include" \ -"\n" - -#include <sys/mman.h> -#include <sys/ioctl.h> -#include <sys/types.h> -#include <sys/time.h> -#include <unistd.h> -#include <fcntl.h> -#include <signal.h> -#include <stdio.h> -#include <stdlib.h> -#include <string.h> - -#include <linux/fb.h> -#include <linux/videodev.h> - -#define VIDEO_DEV "/dev/video0" -#define FB_DEV "/dev/fb0" -#define VT_DEV "/dev/tty0" - -static char *video_devname = VIDEO_DEV; - -#define min(a,b)	(a) < (b) ? (a) : (b) - -static int zero = 0; -static int one = 1; - -static struct fb_var_screeninfo fb_var; -static struct fb_fix_screeninfo fb_fix; - - -int init_fb (void) -{ -	const char blankoff_str[] = "\033[9;0]"; -	int fd, vt_fd; - -	fd = open (FB_DEV, O_RDWR); -	if (fd < 0) { -		perror("Could not open " FB_DEV ", please check permissions\n"); -		return 1; -	} - -	if ((vt_fd = open( VT_DEV, O_RDWR )) < 0) { -		perror("Could not open " VT_DEV ", please check permissions\n"); -		return 1; -	} - -	write( vt_fd, blankoff_str, strlen(blankoff_str) ); - -	if (ioctl (fd, FBIOGET_VSCREENINFO, &fb_var) < 0) { -		perror("Could not get variable screen information (fb_var)\n"); -		return 1; -	} - -	if (ioctl (fd, FBIOGET_FSCREENINFO, &fb_fix) < 0) { -		perror("Could not get fixed screen information (fb_fix)\n"); -		return 1; -	} - -	close (fd); -	return 0; -} - - -int init_video (int stop) -{ -	int fd; -	struct video_capability vcap; - -	if ((fd = open (video_devname, O_RDWR)) < 0) { -		fprintf (stderr, -			 "%s: Could not open %s, please check permissions\n", -			 __FUNCTION__, video_devname); -		return -1; -	} - -	ioctl(fd, VIDIOCGCAP, &vcap); - -	if (ioctl(fd, VIDIOCCAPTURE, &zero) < 0) { -		perror("Could not stop capturing (VIDIOCCAPTURE failed)\n"); -		return -2; -	} - -	if (stop) -		return 0; - -	{ -		struct video_buffer b; -		b.base = (void*) fb_fix.smem_start; -		b.width = fb_var.xres; -		b.height = fb_var.yres; -		b.depth = fb_var.bits_per_pixel; -		b.bytesperline = fb_var.xres*((fb_var.bits_per_pixel+7)/8); -		if (ioctl(fd, VIDIOCSFBUF, &b) < 0) { -			fprintf(stderr, "VIDIOCSFBUF failed, must run as root?\n"); -			return -3; -		} -	} - -	{ -		struct video_picture p; -		if (ioctl(fd, VIDIOCGPICT, &p) < 0) { -			perror("VIDIOCGPICT failed\n"); -			return -4; -		} -		p.depth = fb_var.bits_per_pixel; -		switch (fb_var.bits_per_pixel) { -			case 16: -				p.palette = VIDEO_PALETTE_RGB565; -				break; -			case 24: -				p.palette = VIDEO_PALETTE_RGB24; -				break; -			case 32: -				p.palette = VIDEO_PALETTE_RGB32; -				break; -		} -		//p.contrast = 0x8000; -		//p.colour = 0x6000; -		if (ioctl(fd, VIDIOCSPICT, &p) < 0) { -			perror("VIDIOCSPICT failed\n"); -			return -5; -		} -	} - -	{ -		struct video_window win; -		win.width = min((__u32) vcap.maxwidth, fb_var.xres); -		win.height = min((__u32) vcap.maxheight, fb_var.yres); -		win.x = 0; -		win.y = 0; -		win.flags = 0; -		win.clips = NULL; -		win.clipcount = 0; -		win.chromakey = 0; -		if (ioctl(fd, VIDIOCSWIN, &win) < 0) { -			perror("VIDIOCSWIN failed\n"); -			return -6; -		} -	} - -	if (ioctl(fd, VIDIOCCAPTURE, &one) < 0) { -		perror("Could not start capturing (VIDIOCCAPTURE failed)\n"); -		return -7; -	} - -	close (fd); - -	return 0; -} - -int main (int argc, char **argv) -{ -	int err = 0, stop = 0; - -	if ((err = init_fb())) -		return err; - -	if ((argc == 2 && strcmp(argv[1], "stop") == 0) || -	    (argc == 3 && strcmp(argv[2], "stop") == 0)) -		stop = 1; - -	if ((argc == 2 && !stop) || argc == 3) -		video_devname = argv[1]; - -	if (argc != 1 && argc != 2 && !(argc == 3 && stop)) { -		fprintf(stderr, "usage: %s <devname> <stop>\n" USAGE, argv[0]); -		exit (-1); -	} - -	return init_video (stop); -} | 
