/* $Id: plugin_dvb.c,v 1.3 2004/03/03 03:47:04 reinelt Exp $ * * plugin for DVB status * * Copyright 2003 Michael Reinelt * Copyright 2004 The LCD4Linux Team * * This file is part of LCD4Linux. * * LCD4Linux 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, or (at your option) * any later version. * * LCD4Linux 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. * * * $Log: plugin_dvb.c,v $ * Revision 1.3 2004/03/03 03:47:04 reinelt * big patch from Martin Hejl: * - use qprintf() where appropriate * - save CPU cycles on gettimeofday() * - add quit() functions to free allocated memory * - fixed lots of memory leaks * * Revision 1.2 2004/02/16 13:03:37 reinelt * compile problem with missing frontend.h fixed * * Revision 1.1 2004/02/10 06:54:39 reinelt * DVB plugin ported * */ /* * exported functions: * * int plugin_init_dvb (void) * adds dvb() function * */ #include "config.h" #include #include #include #include #include #include #include #include #include #ifdef HAVE_LINUX_DVB_FRONTEND_H #include #else #warning linux/dvb/frontend.h not found: using hardcoded ioctl definitions #define FE_READ_BER _IOR('o', 70, __u32) #define FE_READ_SIGNAL_STRENGTH _IOR('o', 71, __u16) #define FE_READ_SNR _IOR('o', 72, __u16) #define FE_READ_UNCORRECTED_BLOCKS _IOR('o', 73, __u32) #endif #include "debug.h" #include "plugin.h" #include "hash.h" static char *frontend="/dev/dvb/adapter0/frontend0"; static HASH DVB = { 0, }; static int get_dvb_stats (void) { int age; int fd; unsigned short snr, sig; unsigned long ber, ucb; char val[16]; // reread every 1000 msec only age=hash_age(&DVB, NULL, NULL); if (age>0 && age<=1000) return 0; // open frontend fd = open(frontend, O_RDONLY); if (fd==-1) { error ("open(%s) failed: %s", frontend, strerror(errno)); return -1; } if (ioctl(fd, FE_READ_SIGNAL_STRENGTH, &sig)!=0) { error("ioctl(FE_READ_SIGNAL_STRENGTH) failed: %s", strerror(errno)); sig=0; } if (ioctl(fd, FE_READ_SNR, &snr)!=0) { error("ioctl(FE_READ_SNR) failed: %s", strerror(errno)); snr=0; } if (ioctl(fd, FE_READ_BER, &ber)!=0) { error("ioctl(FE_READ_BER) failed: %s", strerror(errno)); ber=0; } if (ioctl(fd, FE_READ_UNCORRECTED_BLOCKS, &ucb)!=0) { error("ioctl(FE_READ_UNCORRECTED_BLOCKS) failed: %s", strerror(errno)); ucb=0; } close (fd); snprintf (val, sizeof(val), "%f", sig/65535.0); hash_set (&DVB, "signal_strength", val); snprintf (val, sizeof(val), "%f", snr/65535.0); hash_set (&DVB, "snr", val); snprintf (val, sizeof(val), "%lu", ber); hash_set (&DVB, "ber", val); snprintf (val, sizeof(val), "%lu", ucb); hash_set (&DVB, "uncorrected_blocks", val); return 0; } static void my_dvb (RESULT *result, RESULT *arg1) { char *val; if (get_dvb_stats()<0) { SetResult(&result, R_STRING, ""); return; } val=hash_get(&DVB, R2S(arg1)); if (val==NULL) val=""; SetResult(&result, R_STRING, val); } int plugin_init_dvb (void) { AddFunction ("dvb", 3, my_dvb); return 0; } void plugin_exit_dvb(void) { hash_destroy(&DVB); } 0608ae4f&follow=1'>patch from Robert Tesch: support KIT120-5 and KIT129-6, GPO code repaired, us...michael1-20/+58 2012-01-16Patch for Driver EA232Graphic by Robert Reschmichael2-7/+70 2012-01-16scaletext patch from Stefan Kuhnemichael2-4/+16 2012-01-16update to automake 1.11.2michael3-44/+78 2012-01-08DPF driver by Stefan Kuhne 8note that you need libdpf)michael9-4/+337 2012-01-08[PATCH 2/2] gcc warnings by Jonathan McCrohanmichael1-1/+1 2012-01-08ATCH 1/2] gcc warnings by Jonathan McCrohanmichael1-2/+2 2011-12-26old ancient legacy port access disabled by defaultmichael6-162/+491 2011-12-22All compilation related issues in the headers have been fixed. Now each heade...mjona10-0/+11 2011-12-09Replaced parameter NoPowerCycle with PowerCyclesonic741-5/+5 2011-12-09Blit speedup, switch PICASO back to 9600 baud when exitingsonic741-47/+46 2011-12-08Removed compiler warningsonic741-1/+1 2011-12-08SGC supportsonic741-111/+254 2011-08-31Fix spelling errors. Flagged by Debian lintian checkjmccrohan4-4/+4 2011-07-28driver for Futaba MDM166A Graphic(96x16) vf-displays by Andreas Bracholdmichael9-2/+684 2011-07-27driver for Newhaven's NHD‐0420D3Z‐FL‐GBW. 4x20 LCD by Rusty Clarksonmichael9-4/+573 2011-07-27indentation :-(michael1-3/+3 2011-07-27magic bold escape char by Andrew Thompsonmichael1-1/+9 2011-07-27picoLCDGraphics needs keypad linkedmichael2-0/+2 2011-07-27various compiler warnings fixedmichael13-60/+39 2011-07-27Autoconf 2.68michael3-1455/+2751 2011-07-27run smoketest on all of my 8 coresmichael1-2/+2 2011-07-27indentationmichael4-330/+320 2011-07-27patch to replace outdate library libmpd with recent library libmpdclient from...michael2-240/+427 2011-07-27lcd4linux-wireless.patch from Hans de Goedemichael1-1/+1 2011-07-27st2205-width-height-swap.patch from Hans de Goedemichael1-2/+2 2011-07-27hwmon patch from Hans de Goedemichael1-0/+14 2011-07-27patch to support SureElectronicsDE-LD023 from Matt Joicemichael1-3/+16 2011-05-06Fixed keypad widget in GLCD2USBharbaum1-0/+7 2011-02-12timer.c: fixed detection of positive clock skew (and some typos)mzuther4-10/+10 2011-01-23timer.c: fixed clock skew detectionmzuther1-26/+46 2011-01-23timer.c: skip intermediate timer intervalsmzuther2-16/+46 2011-01-05fix for a bug introduced in the DE-LD021 drivermichael1-3/+3 2011-01-04indentationmichael2-3/+3 2011-01-04support for Sure Electronics DE-LD021 by Natanael Olaizmichael1-10/+8 2011-01-02driver for EFN LED modules by Tilman Glötznermichael9-21/+469 2010-11-28commented, corrected and beautified both timer and timer group codemzuther11-197/+511 2010-11-27finished commenting the timer codemzuther2-46/+138 2010-11-20started commenting the timer codemzuther5-52/+170 2010-11-19Added brightness support for GLCD2USBharbaum5-28/+8014