To apply this file, cd to the top of the Tuxbox CVS tree (containing a subdirectory cdk), then use a command like patch -p1 < avsstuff-2006-01-05.diff diff -Naur old/apps/tuxbox/neutrino/daemons/controld/Makefile.am new/apps/tuxbox/neutrino/daemons/controld/Makefile.am --- old/apps/tuxbox/neutrino/daemons/controld/Makefile.am 2006-01-05 12:59:41.000000000 +0100 +++ new/apps/tuxbox/neutrino/daemons/controld/Makefile.am 2006-01-05 11:06:30.000000000 +0100 @@ -5,7 +5,8 @@ @CONNECTION_CFLAGS@ \ @EVENTSERVER_CFLAGS@ \ @TUXBOX_CFLAGS@ \ - @ZAPIT_CFLAGS@ + @ZAPIT_CFLAGS@ \ + @XML_CFLAGS@ bin_PROGRAMS = controld @@ -19,11 +20,20 @@ @TUXBOX_LIBS@ \ @ZAPIT_LIBS@ \ @LIRCDCLIENT_LIBS@ \ + @XML_LIBS@ \ -lpthread controld_SOURCES = controld.cpp eventwatchdog.cpp install-data-local: install -d $(CONFIGDIR) - install -m 644 $(srcdir)/scart.conf $(CONFIGDIR) + install -m 644 $(srcdir)/io-config.xml $(CONFIGDIR) +if MAINTAINER_MODE +# Metamorphosis can be downloaded from http://www.ovidius.com +MMX = /usr/local/mm/bin/mmx + +avs_settings.cpp: io-config.xml do-inits.mm + $(MMX) -M do-inits.mm -F xml -S $< -F txt -T $@ + +endif diff -Naur old/apps/tuxbox/neutrino/daemons/controld/avs_settings.cpp new/apps/tuxbox/neutrino/daemons/controld/avs_settings.cpp --- old/apps/tuxbox/neutrino/daemons/controld/avs_settings.cpp 1970-01-01 01:00:00.000000000 +0100 +++ new/apps/tuxbox/neutrino/daemons/controld/avs_settings.cpp 2006-01-05 11:04:24.000000000 +0100 @@ -0,0 +1,16 @@ +// This file was automatically generated from io-config.xml, do not edit +avs_vendor_settings nokia_settings = { + // v1 a1 v2 a2 v3 a3 fblk + {{1,5,4,5,5}, 1, {{1,2},{1,7},{1,2},{7,7},{1,7}}, 1, {0,0,0,0,0}, 1, 0}, // DVB + {{3,3,3,3,3}, 2, {{1,7},{1,7},{1,7},{1,7},{1,7}}, 2, {3,3,3,3,3}, 2, 2} // Scart +}; +avs_vendor_settings sagem_settings = { + // v1 a1 v2 a2 v3 a3 fblk + {{0,0,1,0,0}, 0, {{0,1},{0,7},{0,1},{7,7},{0,7}}, 0, {0,0,0,0,0}, 0, 0}, // DVB + {{2,2,2,2,2}, 1, {{0,0},{0,0},{0,0},{0,0},{0,0}}, 1, {0,0,0,0,0}, 1, 3} // Scart +}; +avs_vendor_settings philips_settings = { + // v1 a1 v2 a2 v3 a3 fblk + {{1,1,1,1,1}, 1, {{1,1},{1,1},{1,1},{1,1},{1,1}}, 1, {3,3,3,3,3}, 1, 1}, // DVB + {{3,3,3,3,3}, 3, {{2,2},{2,2},{2,2},{2,2},{2,2}}, 2, {1,1,1,1,1}, 2, 2} // Scart +}; diff -Naur old/apps/tuxbox/neutrino/daemons/controld/controld.cpp new/apps/tuxbox/neutrino/daemons/controld/controld.cpp --- old/apps/tuxbox/neutrino/daemons/controld/controld.cpp 2006-01-05 12:59:41.000000000 +0100 +++ new/apps/tuxbox/neutrino/daemons/controld/controld.cpp 2006-01-04 16:28:41.000000000 +0100 @@ -22,7 +22,7 @@ */ #define USE_LIBTUXBOX 1 - +#define CONFIG_FILE #include #include @@ -55,6 +55,10 @@ #include #endif +#ifdef CONFIG_FILE +#include +#endif + #include "eventwatchdog.h" #include "driver/audio.h" @@ -63,7 +67,6 @@ #define AVS_DEVICE "/dev/dbox/avs0" #define SAA7126_DEVICE "/dev/dbox/saa0" - CZapitClient zapit; CTimerdClient timerd; CEventServer *eventServer; @@ -79,28 +82,197 @@ bool mute_avs; bool scale_logarithmic; bool scale_logarithmic_avs; - int videooutput; + CControld::video_format vcroutput; + CControld::video_format videooutput; int videoformat; int csync; CControld::volume_type volume_type; CControld::tuxbox_maker_t boxtype; // not part of the config - set by setBoxType() } settings; -int nokia_scart[7]; -int nokia_dvb[6]; -int sagem_scart[7]; -int sagem_dvb[6]; -int philips_scart[7]; -int philips_dvb[6]; +// A value that can be put into the AVS-Switch (0..7) +typedef unsigned char switchvalue; + +struct tv_format { + switchvalue cvbs; + switchvalue rgb; + switchvalue svideo; + switchvalue yuv_vbs; + switchvalue yuv_cvbs; +}; + +struct vcr_format { + switchvalue cvbs; + switchvalue svideo; +}; + +struct tv_vcr_format { + vcr_format cvbs; + vcr_format rgb; + vcr_format svideo; + vcr_format yuv_vbs; + vcr_format yuv_cvbs; +}; + +struct avs_settings { + tv_format v1; + switchvalue a1; + tv_vcr_format v2; + switchvalue a2; + tv_format v3; + switchvalue a3; + switchvalue fblk; +}; + +struct avs_vendor_settings { + avs_settings dvb_settings; + avs_settings scart_settings; +}; + +avs_vendor_settings current_avs_settings; char aspectRatio_vcr; char aspectRatio_dvb; bool vcr; bool videoOutputDisabled; - +void routeVideo(); void sig_catch(int); +#include "avs_settings.cpp" + +#ifdef CONFIG_FILE +XMLTreeNode *get_child_by_attribute_value(XMLTreeNode *parent, const char *attname, const char *attval) { + XMLTreeNode *n; + for (n = parent->GetChild(); n; n = n->GetNext()) { + if (n->GetAttributeValue((char*)attname) && strcmp(n->GetAttributeValue((char*)attname), attval) == 0) { + return n; + } + } + printf("[controld]: get_child_by_attribute_value not found: %s %s\n", attname, attval); + return NULL; +} + +XMLTreeNode *get_child_by_type(XMLTreeNode *parent, const char *gid) { + XMLTreeNode *n; + for (n = parent->GetChild(); n; n = n->GetNext()) { + if (n->GetType() && strcmp(n->GetType(), gid) == 0) { + return n; + } + } + printf("[controld]: get_child_by_type failed: %s\n", gid); + return NULL; +} + +switchvalue get_child_value_attribute(XMLTreeNode *parent, const char* gid) { + if (!parent) + return 7; + XMLTreeNode *n = get_child_by_type(parent, gid); + if (n) + return strtol(n->GetAttributeValue("value"), 0, 10); + else + return 7; +} + +switchvalue get_tv_format(XMLTreeNode *n, const char *format) { + return get_child_value_attribute(get_child_by_attribute_value(n, "format", format), "v1"); +} + +switchvalue get_v3_format(XMLTreeNode *n, const char *format) { + return get_child_value_attribute(get_child_by_attribute_value(n, "format", format), "v3"); +} + +void setup_tv_format(tv_format &fmt, XMLTreeNode *n) { + fmt.cvbs = get_tv_format(n, "cvbs"); + fmt.rgb = get_tv_format(n, "rgb"); + fmt.svideo = get_tv_format(n, "svideo"); + fmt.yuv_vbs = get_tv_format(n, "yuv_vbs"); + fmt.yuv_cvbs = get_tv_format(n, "yuv_cvbs"); +} + +void setup_v3_format(tv_format &fmt, XMLTreeNode *n) { + fmt.cvbs = get_v3_format(n, "cvbs"); + fmt.rgb = get_v3_format(n, "rgb"); + fmt.svideo = get_v3_format(n, "svideo"); + fmt.yuv_vbs = get_v3_format(n, "yuv_vbs"); + fmt.yuv_cvbs = get_v3_format(n, "yuv_cvbs"); +} + +void setup_vcr_format(vcr_format &fmt, XMLTreeNode *n) { + fmt.cvbs = get_child_value_attribute(get_child_by_attribute_value(n, "format", "cvbs"), "v2"); + fmt.svideo = get_child_value_attribute(get_child_by_attribute_value(n, "format", "svideo"), "v2"); +} + +void setup_tv_vcr_format(tv_vcr_format &fmt, XMLTreeNode *n) { + setup_vcr_format(fmt.cvbs, get_child_by_attribute_value(n, "format", "cvbs")); + setup_vcr_format(fmt.rgb, get_child_by_attribute_value(n, "format", "rgb")); + setup_vcr_format(fmt.svideo, get_child_by_attribute_value(n, "format", "svideo")); + setup_vcr_format(fmt.yuv_vbs, get_child_by_attribute_value(n, "format", "yuv_vbs")); + setup_vcr_format(fmt.yuv_cvbs, get_child_by_attribute_value(n, "format", "yuv_cvbs")); +} + +void setup_avs_settings(avs_settings &settings, XMLTreeNode *n) { + setup_tv_format(settings.v1, n); + setup_tv_vcr_format(settings.v2, n); + setup_v3_format(settings.v3, n); + settings.a1 = get_child_value_attribute(n, "a1"); + settings.a2 = get_child_value_attribute(n, "a2"); + settings.a3 = get_child_value_attribute(n, "a3"); + settings.fblk = get_child_value_attribute(n, "fblk"); +} + +bool read_current_avs_settings_from_file() { + XMLTreeParser *tree_parser = new XMLTreeParser("UTF-8"); + FILE *xml_file = fopen("/var/tuxbox/config/io-config.xml", "r"); + if (! xml_file) { + printf("[controld]: Could not open configuration file io-config.xml, using defaults\n"); + return false; + } + + unsigned int length; + char buffer[2048]; + bool done; + + do { + length = fread(buffer, 1, sizeof(buffer), xml_file); + done = length < sizeof(buffer); + + if (!tree_parser->Parse(buffer, length, done)) { + printf("[controld]: Error parsing io-config.xml: %s at line %d, using defaults.", + tree_parser->ErrorString(tree_parser->GetErrorCode()), + tree_parser->GetCurrentLineNumber()); + fclose(xml_file); + delete tree_parser; + return false; + } + } while (!done); + fclose(xml_file); + + if (!tree_parser->RootNode()) { + delete tree_parser; + printf("[controld]: parse error in io-config.xml. Using defaults.\n"); + } + + XMLTreeNode *vendor = get_child_by_attribute_value(tree_parser->RootNode(), "name", + (settings.boxtype == CControld::TUXBOX_MAKER_NOKIA ? "nokia" : + settings.boxtype == CControld::TUXBOX_MAKER_SAGEM ? "sagem" : "philips")); + if (vendor == NULL) { + printf("[controld]: Could not open vendor in io-config.xml, using defaults\n"); + return false; + } + XMLTreeNode *dvb = get_child_by_attribute_value(vendor, "mode", "dvb"); + XMLTreeNode *scart = get_child_by_attribute_value(vendor, "mode", "scart"); + if ((dvb == NULL) || (scart == NULL)) { + printf("[controld]: Could not find dvb and scart in io-config.xml, using defaults\n"); + return false; + } + + setup_avs_settings(current_avs_settings.dvb_settings, dvb); + setup_avs_settings(current_avs_settings.scart_settings, scart); + return true; +} +#endif // CONFIG_FILE + class CControldAspectRatioNotifier : public CAspectRatioNotifier { public: @@ -153,24 +325,25 @@ return val; } -void setvideooutput(int format, bool bSaveSettings = true) +void setvcroutput(CControld::video_format format) { + if ((format != CControld::FORMAT_CVBS) && (format != CControld::FORMAT_SVIDEO)) { + printf("[controld] illegal format (=%d) specified for VCR output (using CVBS)!", format); + format = CControld::FORMAT_CVBS; + } + settings.vcroutput = format; + config->setInt32("vcroutput", settings.vcroutput); + routeVideo(); +} + +void setvideooutput(CControld::video_format format, bool bSaveSettings = true) { int fd; - if (format < 0) + if ((format < 0) || (format >= CControld::no_video_formats)) { - format=0; - } - if (format > 5) - { - format=5; + printf("[controld] illegal format (= %d) specified (using CVBS)!", format); + format=CControld::FORMAT_CVBS; } - // 0 - CVBS only - // 1 - RGB with CVBS - // 2 - SVIDEO - // 3 - YUV with VBS - // 4 - YUV with CVBS - if (bSaveSettings) // only set settings if we dont come from watchdog { settings.videooutput = format; @@ -179,49 +352,23 @@ int arg; - switch (format) - { - case 0: - arg = 0; - break; - case 1: - arg = 1; - break; - case 2: - arg = 0; - break; - case 3: - arg = 1; - break; - case 4: - arg = 1; - break; - } - - if ((fd = open(AVS_DEVICE, O_RDWR)) < 0) - perror("[controld] " AVS_DEVICE); - else { - if (ioctl(fd, AVSIOSFBLK, &arg)< 0) - perror("[controld] AVSIOSFBLK"); - - close(fd); - } + routeVideo(); switch (format) { - case 0: + case CControld::FORMAT_CVBS: arg = SAA_MODE_FBAS; break; - case 1: + case CControld::FORMAT_RGB: arg = SAA_MODE_RGB; break; - case 2: + case CControld::FORMAT_SVIDEO: arg = SAA_MODE_SVIDEO; break; - case 3: + case CControld::FORMAT_YUV_VBS: arg = SAA_MODE_YUV_V; break; - case 4: + case CControld::FORMAT_YUV_CVBS: arg = SAA_MODE_YUV_C; break; } @@ -236,12 +383,13 @@ close(fd); } - if(format == 1 || format == 3 || format == 4) + if(format == CControld::FORMAT_RGB || format == CControld::FORMAT_YUV_VBS || format == CControld::FORMAT_YUV_VBS) setRGBCsync(settings.csync); } void setVideoFormat(int format, bool bSaveFormat = true ) { + static int last_videoformat = AVS_FNCOUT_EXT43; int fd; video_display_format_t videoDisplayFormat; int avsiosfncFormat; @@ -348,186 +496,134 @@ close(fd); } -} - -void LoadScart_Settings() -{ - // scart - sagem_scart[0]= 2; - sagem_scart[1]= 1; - sagem_scart[2]= 0; - sagem_scart[3]= 0; - sagem_scart[4]= 0; - sagem_scart[5]= 0; - sagem_scart[6]= 0; - - nokia_scart[0]= 3; - nokia_scart[1]= 2; - nokia_scart[2]= 1; - nokia_scart[3]= 0; - nokia_scart[4]= 1; - nokia_scart[5]= 1; - nokia_scart[6]= 2; - - philips_scart[0]= 2; - philips_scart[1]= 2; - philips_scart[2]= 3; - philips_scart[3]= 0; - philips_scart[4]= 3; - philips_scart[5]= 0; - philips_scart[6]= 2; - - // dvb - sagem_dvb[0]= 0; - sagem_dvb[1]= 0; - sagem_dvb[2]= 0; - sagem_dvb[3]= 0; - sagem_dvb[4]= 0; - sagem_dvb[5]= 0; - - nokia_dvb[0]= 5; - nokia_dvb[1]= 1; - nokia_dvb[2]= 1; - nokia_dvb[3]= 0; - nokia_dvb[4]= 1; - nokia_dvb[5]= 0; - - philips_dvb[0]= 1; - philips_dvb[1]= 1; - philips_dvb[2]= 1; - philips_dvb[3]= 0; - philips_dvb[4]= 1; - philips_dvb[5]= 0; - - FILE* fd = fopen(CONFIGDIR"/scart.conf", "r"); - if(fd) - { - printf("[controld]: loading scart-config (scart.conf)\n"); - - char buf[1000]; - fgets(buf,sizeof(buf),fd); - if(fgets(buf,sizeof(buf),fd)!=NULL) - { - if(strlen(buf) > 26) - sscanf( buf, "nokia_scart: %d %d %d %d %d %d %d\n", &nokia_scart[0], &nokia_scart[1], &nokia_scart[2], &nokia_scart[3], &nokia_scart[4], &nokia_scart[5], &nokia_scart[6] ); - else - sscanf( buf, "nokia_scart: %d %d %d %d %d %d\n", &nokia_scart[0], &nokia_scart[1], &nokia_scart[2], &nokia_scart[3], &nokia_scart[4], &nokia_scart[5] ); - //printf( buf ); - } - if(fgets(buf,sizeof(buf),fd)!=NULL) - { - sscanf( buf, "nokia_dvb: %d %d %d %d %d %d\n", &nokia_dvb[0], &nokia_dvb[1], &nokia_dvb[2], &nokia_dvb[3], &nokia_dvb[4], &nokia_dvb[5] ); - //printf( buf ); - } - if(fgets(buf,sizeof(buf),fd)!=NULL) - { - if(strlen(buf) > 26) - sscanf( buf, "sagem_scart: %d %d %d %d %d %d %d\n", &sagem_scart[0], &sagem_scart[1], &sagem_scart[2], &sagem_scart[3], &sagem_scart[4], &sagem_scart[5], &sagem_scart[6] ); - else - sscanf( buf, "sagem_scart: %d %d %d %d %d %d\n", &sagem_scart[0], &sagem_scart[1], &sagem_scart[2], &sagem_scart[3], &sagem_scart[4], &sagem_scart[5] ); - //printf( buf ); - } - if(fgets(buf,sizeof(buf),fd)!=NULL) - { - sscanf( buf, "sagem_dvb: %d %d %d %d %d %d\n", &sagem_dvb[0], &sagem_dvb[1], &sagem_dvb[2], &sagem_dvb[3], &sagem_dvb[4], &sagem_dvb[5] ); - //printf( buf ); - } - if(fgets(buf,sizeof(buf),fd)!=NULL) - { - if(strlen(buf) > 26) - sscanf( buf, "philips_scart: %d %d %d %d %d %d %d\n", &philips_scart[0], &philips_scart[1], &philips_scart[2], &philips_scart[3], &philips_scart[4], &philips_scart[5], &philips_scart[6] ); - else - sscanf( buf, "philips_scart: %d %d %d %d %d %d\n", &philips_scart[0], &philips_scart[1], &philips_scart[2], &philips_scart[3], &philips_scart[4], &philips_scart[5] ); - //printf( buf ); - } - if(fgets(buf,sizeof(buf),fd)!=NULL) - { - sscanf( buf, "philips_dvb: %d %d %d %d %d %d\n", &philips_dvb[0], &philips_dvb[1], &philips_dvb[2], &philips_dvb[3], &philips_dvb[4], &philips_dvb[5] ); - //printf( buf ); - } - fclose(fd); - } - else - { - printf("[controld]: failed to load scart-config (scart.conf), using standard-values\n"); + if (format != last_videoformat) { + switch (format) { + case AVS_FNCOUT_EXT169: + { + CIRSend irs("16:9"); + irs.Send(); + } + break; + case AVS_FNCOUT_EXT43: + { + CIRSend irs("4:3"); + irs.Send(); + } + break; + default: + break; + } + last_videoformat = format; } } - -void routeVideo(int v1, int a1, int v2, int a2, int v3, int a3, int fblk) +void routeVideo(int v1, int a1, + int v2, int a2, + int v3, int a3, int fblk) { - int fd; + if (settings.boxtype == CControld::TUXBOX_MAKER_SAGEM) + printf("[controld]: ROUTEVIDEO v1 = %d a1 = %d v2 = %d a2 = %d fblk=%d\n", v1, a1, v2, a2, fblk); + else + printf("[controld]: ROUTEVIDEO v1 = %d a1 = %d v2 = %d a2 = %d v3 = %d a3 = %d fblk=%d\n", v1, a1, v2, a2, v3, a3, fblk); - if ((fd = open(AVS_DEVICE, O_RDWR)) < 0) + int fd = open(AVS_DEVICE, O_RDWR); + if (fd < 0) perror("[controld] " AVS_DEVICE); + else + { + if (ioctl(fd, AVSIOSFBLK, &fblk) < 0) + perror("[controld] AVSIOSFBLK"); - else if (ioctl(fd, AVSIOSFBLK, &fblk) < 0) - perror("[controld] AVSIOSFBLK"); - - else if (ioctl(fd, AVSIOSVSW1, &v1) < 0) - perror("[controld] AVSIOSVSW1"); + if (ioctl(fd, AVSIOSVSW1, &v1) < 0) + perror("[controld] AVSIOSVSW1"); - else if (ioctl(fd, AVSIOSASW1, &a1) < 0) - perror("[controld] AVSIOSASW1"); + if (ioctl(fd, AVSIOSASW1, &a1) < 0) + perror("[controld] AVSIOSASW1"); - else if (ioctl(fd, AVSIOSVSW2, &v2) < 0) - perror("[controld] AVSIOSVSW2"); + if (ioctl(fd, AVSIOSVSW2, &v2) < 0) + perror("[controld] AVSIOSVSW2"); - else if (ioctl(fd, AVSIOSASW2, &a2) < 0) - perror("[controld] AVSIOSASW2"); + if (ioctl(fd, AVSIOSASW2, &a2) < 0) + perror("[controld] AVSIOSASW2"); - else if (ioctl(fd, AVSIOSVSW3, &v3) < 0) - perror("[controld] AVSIOSVSW3"); + // Sagem does not have v3 and a3, see CXA2126 data sheet + if (settings.boxtype != CControld::TUXBOX_MAKER_SAGEM) { + if (ioctl(fd, AVSIOSVSW3, &v3) < 0) + perror("[controld] AVSIOSVSW3"); - else if (ioctl(fd, AVSIOSASW3, &a3) < 0) - perror("[controld] AVSIOSASW3"); + if (ioctl(fd, AVSIOSASW3, &a3) < 0) + perror("[controld] AVSIOSASW3"); + } + } if (fd != -1) close(fd); } +void routeVideo() { +#ifdef CONFIG_FILE + read_current_avs_settings_from_file(); +#endif + avs_settings f = vcr ? current_avs_settings.scart_settings : current_avs_settings.dvb_settings; + + switchvalue v1, v3; + vcr_format vcr_switches; + + switch (settings.videooutput) { + case CControld::FORMAT_RGB: + v1 = f.v1.rgb; + vcr_switches = f.v2.rgb; + v3 = f.v3.rgb; + break; + case CControld::FORMAT_SVIDEO: + v1 = f.v1.svideo; + vcr_switches = f.v2.svideo; + v3 = f.v3.svideo; + break; + case CControld::FORMAT_YUV_VBS: + v1 = f.v1.yuv_vbs; + vcr_switches = f.v2.yuv_vbs; + v3 = f.v3.yuv_vbs; + break; + case CControld::FORMAT_YUV_CVBS: + v1 = f.v1.yuv_cvbs; + vcr_switches = f.v2.yuv_cvbs; + v3 = f.v3.yuv_cvbs; + break; + default: + // case CControld::FORMAT_CVBS: + v1 = f.v1.cvbs; + vcr_switches = f.v2.cvbs; + v3 = f.v3.cvbs; + break; + }; + + switchvalue v2 = settings.vcroutput == CControld::FORMAT_SVIDEO ? vcr_switches.svideo : vcr_switches.cvbs; + + switchvalue fblk = vcr ? f.fblk : (settings.videooutput == CControld::FORMAT_RGB) ? 1 : 0; + + routeVideo(v1, f.a1, v2, f.a2, v3, f.a3, fblk); +} + void switch_vcr( bool vcr_on) { int activeAspectRatio; - LoadScart_Settings(); vcr = vcr_on; if (vcr_on) { //turn to scart-input - activeAspectRatio = aspectRatio_vcr; + activeAspectRatio = aspectRatio_vcr; printf("[controld]: switch to scart-input... (%d)\n", settings.boxtype); - if (settings.boxtype == CControld::TUXBOX_MAKER_SAGEM) - { - routeVideo(sagem_scart[0], sagem_scart[1], sagem_scart[2], sagem_scart[3], sagem_scart[4], sagem_scart[5], sagem_scart[6]); - } - else if (settings.boxtype == CControld::TUXBOX_MAKER_NOKIA) - { - routeVideo(nokia_scart[0], nokia_scart[1], nokia_scart[2], nokia_scart[3], nokia_scart[4], nokia_scart[5], nokia_scart[6]); - } - else if (settings.boxtype == CControld::TUXBOX_MAKER_PHILIPS) - { - routeVideo(philips_scart[0], philips_scart[1], philips_scart[2], philips_scart[3], philips_scart[4], philips_scart[5], philips_scart[6]); - } } else { //turn to dvb... - activeAspectRatio = aspectRatio_dvb; + activeAspectRatio = aspectRatio_dvb; printf("[controld]: switch to dvb-input... (%d)\n", settings.boxtype); - if (settings.boxtype == CControld::TUXBOX_MAKER_SAGEM) - { - routeVideo( sagem_dvb[0], sagem_dvb[1], sagem_dvb[2], sagem_dvb[3], sagem_dvb[4], sagem_dvb[5], settings.videooutput); - } - else if (settings.boxtype == CControld::TUXBOX_MAKER_NOKIA) - { - routeVideo( nokia_dvb[0], nokia_dvb[1], nokia_dvb[2], nokia_dvb[3], nokia_dvb[4], nokia_dvb[5], settings.videooutput); - } - else if (settings.boxtype == CControld::TUXBOX_MAKER_PHILIPS) - { - routeVideo( philips_dvb[0], philips_dvb[1], philips_dvb[2], philips_dvb[3], philips_dvb[4], philips_dvb[5], settings.videooutput); - } } + routeVideo(); + // recall AspectRatio when switching between DVB and VCR if ( settings.videoformat == 0 ) { @@ -605,7 +701,7 @@ } else { - setvideooutput(0, false); + setvideooutput(CControld::FORMAT_CVBS, false); setVideoFormat(-1, false); //zapit.setStandby(true); zapit.muteAudio(true); @@ -820,7 +916,7 @@ //printf("[controld] set videooutput\n"); CControldMsg::commandVideoOutput msg3; CBasicServer::receive_data(connfd, &msg3, sizeof(msg3)); - setvideooutput(msg3.output); + setvideooutput((CControld::video_format)msg3.output); break; case CControldMsg::CMD_SETBOXTYPE: //printf("[controld] set boxtype\n"); //-------------------dummy!!!!!!!!!! @@ -887,6 +983,19 @@ eventServer->unRegisterEvent(connfd); break; + case CControldMsg::CMD_SETVCROUTPUT: + //printf("[controld] set vcroutput\n"); + CControldMsg::commandVCROutput msg13; + CBasicServer::receive_data(connfd, &msg13, sizeof(msg13)); + setvcroutput((CControld::video_format)msg13.vcr_output); + break; + case CControldMsg::CMD_GETVCROUTPUT: + //printf("[controld] get vcroutput\n"); + CControldMsg::responseVCROutput msg14; + msg14.vcr_output = settings.vcroutput; + CBasicServer::send_data(connfd,&msg14,sizeof(msg14)); + break; + default: printf("[controld] unknown command\n"); } @@ -983,7 +1092,8 @@ settings.mute_avs = config->getBool("mute_avs", false); settings.scale_logarithmic = config->getBool("scale_logarithmic", true); settings.scale_logarithmic_avs = config->getBool("scale_logarithmic_avs", true); - settings.videooutput = config->getInt32("videooutput", 1); // fblk1 - rgb + settings.vcroutput = (CControld::video_format) config->getInt32("vcroutput", CControld::FORMAT_CVBS); + settings.videooutput = (CControld::video_format) config->getInt32("videooutput", CControld::FORMAT_RGB); settings.videoformat = config->getInt32("videoformat", 2); // fnc2 - 4:3 settings.csync = config->getInt32("csync", 0); settings.volume_type = (CControld::volume_type) config->getInt32("volume_type", CControld::TYPE_OST); @@ -1008,6 +1118,11 @@ vcr=false; videoOutputDisabled=false; + current_avs_settings = + settings.boxtype == CControld::TUXBOX_MAKER_NOKIA ? nokia_settings : + settings.boxtype == CControld::TUXBOX_MAKER_SAGEM ? sagem_settings : + philips_settings; + controld_server.run(parse_command, CControldMsg::ACTVERSION); shutdownBox(); diff -Naur old/apps/tuxbox/neutrino/daemons/controld/do-inits.mm new/apps/tuxbox/neutrino/daemons/controld/do-inits.mm --- old/apps/tuxbox/neutrino/daemons/controld/do-inits.mm 1970-01-01 01:00:00.000000000 +0100 +++ new/apps/tuxbox/neutrino/daemons/controld/do-inits.mm 2006-01-05 11:04:19.000000000 +0100 @@ -0,0 +1,48 @@ +!transformation + +!begin [] +"// This file was automatically generated from ", +sourcenames, +", do not edit\n", +source.child; + +vendor [] +!replace +"avs_vendor_settings ", + self.@name, + "_settings = {\n", + " // v1 a1 v2 a2 v3 a3 fblk\n", + + self.r.child[@mode == "dvb"], + ", // DVB\n", + self.r.child[@mode == "scart"], + " // Scart\n};\n"; + +operating-mode [] +!replace +" {{", + join(self.r.child[?tv-format].child[?v1].@value, ","), + "}, ", + self.r.child[?a1], + ", {", + self.r.child[?tv-format], + "}, ", + self.r.child[?a2], ", {", + join(self.r.child[?tv-format].child[?v3].@value, ","), + "}, ", + self.r.child[?a3], ", ", + self.r.child[?fblk], +"}"; + +v1|v2|a1|a2|a3|fblk [] +!replace self.@value; + +tv-format [] +!replace +(self.r.left & ","), +"{", + self.r.child[@format == "cvbs"], + ",", + self.r.child[@format == "svideo"], + "}" + ; diff -Naur old/apps/tuxbox/neutrino/daemons/controld/io-config.dtd new/apps/tuxbox/neutrino/daemons/controld/io-config.dtd --- old/apps/tuxbox/neutrino/daemons/controld/io-config.dtd 1970-01-01 01:00:00.000000000 +0100 +++ new/apps/tuxbox/neutrino/daemons/controld/io-config.dtd 2005-12-11 18:29:44.000000000 +0100 @@ -0,0 +1,54 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff -Naur old/apps/tuxbox/neutrino/daemons/controld/io-config.xml new/apps/tuxbox/neutrino/daemons/controld/io-config.xml --- old/apps/tuxbox/neutrino/daemons/controld/io-config.xml 1970-01-01 01:00:00.000000000 +0100 +++ new/apps/tuxbox/neutrino/daemons/controld/io-config.xml 2006-01-05 10:55:18.000000000 +0100 @@ -0,0 +1,346 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff -Naur old/apps/tuxbox/neutrino/data/locale/deutsch.locale new/apps/tuxbox/neutrino/data/locale/deutsch.locale --- old/apps/tuxbox/neutrino/data/locale/deutsch.locale 2006-01-05 12:59:41.000000000 +0100 +++ new/apps/tuxbox/neutrino/data/locale/deutsch.locale 2005-12-11 18:22:49.000000000 +0100 @@ -1021,6 +1021,10 @@ videomenu.head Video-Einstellungen videomenu.rgb_centering RGB-Zentrierung videomenu.screensetup Bildbereich einstellen +videomenu.vcrsignal VCR-Ausgang Signalart +videomenu.vcrsignal_composite CVBS +videomenu.vcrsignal_svideo S-Video +videomenu.vcrsignal_svideo_failure S-Video auf VCR nicht möglich mit gewältem TV Signalart. videomenu.vcrswitch Scart-Eingang automatisch videomenu.videoformat Bildschirmformat videomenu.videoformat_169 16:9 diff -Naur old/apps/tuxbox/neutrino/data/locale/english.locale new/apps/tuxbox/neutrino/data/locale/english.locale --- old/apps/tuxbox/neutrino/data/locale/english.locale 2006-01-05 12:59:42.000000000 +0100 +++ new/apps/tuxbox/neutrino/data/locale/english.locale 2006-01-05 11:35:32.000000000 +0100 @@ -1021,6 +1021,10 @@ videomenu.head Video Settings videomenu.rgb_centering RGB centering videomenu.screensetup Screen Setup +videomenu.vcrsignal VCR-Output Signal +videomenu.vcrsignal_composite CVBS +videomenu.vcrsignal_svideo S-Video +videomenu.vcrsignal_svideo_failure S-Video for VCR not possible with the selected TV signal. videomenu.vcrswitch Switch Scart automatically videomenu.videoformat Format videomenu.videoformat_169 16:9 diff -Naur old/apps/tuxbox/neutrino/lib/controldclient/controldMsg.h new/apps/tuxbox/neutrino/lib/controldclient/controldMsg.h --- old/apps/tuxbox/neutrino/lib/controldclient/controldMsg.h 2006-01-05 12:59:42.000000000 +0100 +++ new/apps/tuxbox/neutrino/lib/controldclient/controldMsg.h 2005-11-26 18:41:40.000000000 +0100 @@ -57,6 +57,9 @@ CMD_SETVIDEOOUTPUT, CMD_GETVIDEOOUTPUT, + CMD_SETVCROUTPUT, + CMD_GETVCROUTPUT, + CMD_SETBOXTYPE, CMD_GETBOXTYPE, @@ -98,6 +101,11 @@ unsigned char output; }; + struct commandVCROutput + { + unsigned char vcr_output; + }; + struct commandBoxType { CControld::tuxbox_maker_t boxtype; @@ -130,6 +138,11 @@ unsigned char output; }; + struct responseVCROutput + { + unsigned char vcr_output; + }; + struct responseBoxType { CControld::tuxbox_maker_t boxtype; diff -Naur old/apps/tuxbox/neutrino/lib/controldclient/controldclient.cpp new/apps/tuxbox/neutrino/lib/controldclient/controldclient.cpp --- old/apps/tuxbox/neutrino/lib/controldclient/controldclient.cpp 2006-01-05 12:59:42.000000000 +0100 +++ new/apps/tuxbox/neutrino/lib/controldclient/controldclient.cpp 2005-11-26 18:44:28.000000000 +0100 @@ -155,6 +155,17 @@ close_connection(); } +void CControldClient::setVCROutput(char output) +{ + CControldMsg::commandVCROutput msg2; + + msg2.vcr_output = output; + + send(CControldMsg::CMD_SETVCROUTPUT, (char*)&msg2, sizeof(msg2)); + + close_connection(); +} + char CControldClient::getVideoOutput() { CControldMsg::responseVideoOutput rmsg; @@ -168,6 +179,19 @@ return success ? rmsg.output : 1; /* default value is 1 (cf. controld.cpp) */ } +char CControldClient::getVCROutput() +{ + CControldMsg::responseVCROutput rmsg; + + send(CControldMsg::CMD_GETVCROUTPUT); + + bool success = receive_data((char*)&rmsg, sizeof(rmsg)); + + close_connection(); + + return success ? rmsg.vcr_output : 1; /* default value is 1 (cf. controld.cpp) */ +} + void CControldClient::Mute(const CControld::volume_type volume_type) { setMute(true,volume_type); diff -Naur old/apps/tuxbox/neutrino/lib/controldclient/controldclient.h new/apps/tuxbox/neutrino/lib/controldclient/controldclient.h --- old/apps/tuxbox/neutrino/lib/controldclient/controldclient.h 2006-01-05 12:59:42.000000000 +0100 +++ new/apps/tuxbox/neutrino/lib/controldclient/controldclient.h 2005-12-16 20:45:15.000000000 +0100 @@ -126,6 +126,14 @@ void setVideoOutput(char); char getVideoOutput(); + /* + setVCROutput(char) : Setzten des Videooutputs für VCR ( composite / svideo ) + Parameter: VIDEOOUTPUT_COMPOSITE = cvbs + VIDEOOUTPUT_SVIDEO = svideo + */ + void setVCROutput(char); + char getVCROutput(); + /* setBoxType(CControldClient::tuxbox_vendor_t) : Setzten des Boxentyps ( nokia / sagem / philips ) */ diff -Naur old/apps/tuxbox/neutrino/lib/controldclient/controldtypes.h new/apps/tuxbox/neutrino/lib/controldclient/controldtypes.h --- old/apps/tuxbox/neutrino/lib/controldclient/controldtypes.h 2006-01-05 12:59:42.000000000 +0100 +++ new/apps/tuxbox/neutrino/lib/controldclient/controldtypes.h 2005-12-17 12:13:36.000000000 +0100 @@ -40,11 +40,23 @@ } tuxbox_maker_t; enum volume_type - { + { TYPE_OST=0, TYPE_AVS=1, TYPE_LIRC=2, TYPE_UNKNOWN }; + + const static int no_video_formats = 5; + + typedef enum video_format + { + FORMAT_CVBS = 0, + FORMAT_RGB = 1, + FORMAT_SVIDEO = 2, + FORMAT_YUV_VBS = 3, + FORMAT_YUV_CVBS = 4 + }; + }; #endif diff -Naur old/apps/tuxbox/neutrino/src/neutrino.cpp new/apps/tuxbox/neutrino/src/neutrino.cpp --- old/apps/tuxbox/neutrino/src/neutrino.cpp 2006-01-05 12:59:42.000000000 +0100 +++ new/apps/tuxbox/neutrino/src/neutrino.cpp 2006-01-05 12:12:18.000000000 +0100 @@ -2062,6 +2062,13 @@ { 0, LOCALE_VIDEOMENU_VIDEOSIGNAL_COMPOSITE } }; +#define VIDEOMENU_VCRSIGNAL_OPTION_COUNT 2 +const CMenuOptionChooser::keyval VIDEOMENU_VCRSIGNAL_OPTIONS[VIDEOMENU_VCRSIGNAL_OPTION_COUNT] = +{ + { 2, LOCALE_VIDEOMENU_VCRSIGNAL_SVIDEO }, + { 0, LOCALE_VIDEOMENU_VCRSIGNAL_COMPOSITE } +}; + #define VIDEOMENU_VIDEOFORMAT_OPTION_COUNT 4 const CMenuOptionChooser::keyval VIDEOMENU_VIDEOFORMAT_OPTIONS[VIDEOMENU_VIDEOFORMAT_OPTION_COUNT] = { @@ -2077,6 +2084,7 @@ CRGBCSyncControler RGBCSyncControler; CScreenSetup ScreenSetup; int video_out_signal; + int vcr_video_out_signal; public: CVideoSettings() : CMenuWidget(LOCALE_VIDEOMENU_HEAD, "video.raw"), RGBCSyncControler(LOCALE_VIDEOMENU_RGB_CENTERING, &g_settings.video_csync) @@ -2087,6 +2095,7 @@ addItem(new CMenuOptionChooser(LOCALE_VIDEOMENU_VIDEOSIGNAL, &video_out_signal, VIDEOMENU_VIDEOSIGNAL_OPTIONS, VIDEOMENU_VIDEOSIGNAL_OPTION_COUNT, true, this)); + addItem(new CMenuOptionChooser(LOCALE_VIDEOMENU_VCRSIGNAL, &vcr_video_out_signal, VIDEOMENU_VCRSIGNAL_OPTIONS, VIDEOMENU_VCRSIGNAL_OPTION_COUNT, true, this)); SyncControlerForwarder = new CMenuForwarder(LOCALE_VIDEOMENU_RGB_CENTERING, false, NULL, &RGBCSyncControler); addItem(SyncControlerForwarder); @@ -2109,10 +2118,19 @@ { if (ARE_LOCALES_EQUAL(OptionName, LOCALE_VIDEOMENU_VIDEOSIGNAL)) { + while ((vcr_video_out_signal) == CControldClient::VIDEOOUTPUT_SVIDEO && (video_out_signal != CControldClient::VIDEOOUTPUT_SVIDEO) && (video_out_signal != CControldClient::VIDEOOUTPUT_COMPOSITE) ) + video_out_signal = (video_out_signal + 1) % 5; g_Controld->setVideoOutput(video_out_signal); SyncControlerForwarder->setActive((video_out_signal == CControldClient::VIDEOOUTPUT_RGB) || (video_out_signal == CControldClient::VIDEOOUTPUT_YUV_VBS) || (video_out_signal == CControldClient::VIDEOOUTPUT_YUV_CVBS)); } + else if (ARE_LOCALES_EQUAL(OptionName, LOCALE_VIDEOMENU_VCRSIGNAL)) + { + if ((vcr_video_out_signal) == CControldClient::VIDEOOUTPUT_SVIDEO && (video_out_signal != CControldClient::VIDEOOUTPUT_SVIDEO) && (video_out_signal != CControldClient::VIDEOOUTPUT_COMPOSITE) ) + DisplayErrorMessage(g_Locale->getText(LOCALE_VIDEOMENU_VCRSIGNAL_SVIDEO_FAILURE)); + else + g_Controld->setVCROutput(vcr_video_out_signal); + } else if (ARE_LOCALES_EQUAL(OptionName, LOCALE_VIDEOMENU_VIDEOFORMAT)) { g_Controld->setVideoFormat(g_settings.video_Format); @@ -2124,8 +2142,9 @@ virtual void paint() { video_out_signal = g_Controld->getVideoOutput(); + vcr_video_out_signal = g_Controld->getVCROutput(); - SyncControlerForwarder->active = ((video_out_signal == CControldClient::VIDEOOUTPUT_RGB) || (video_out_signal == CControldClient::VIDEOOUTPUT_YUV_VBS) || (video_out_signal == CControldClient::VIDEOOUTPUT_YUV_CVBS)); + SyncControlerForwarder->active = ((video_out_signal == CControldClient::VIDEOOUTPUT_RGB) || (video_out_signal == CControldClient::VIDEOOUTPUT_YUV_VBS) || (video_out_signal == CControldClient::VIDEOOUTPUT_YUV_CVBS)); g_settings.video_Format = g_Controld->getVideoFormat(); diff -Naur old/apps/tuxbox/neutrino/src/system/locals.h new/apps/tuxbox/neutrino/src/system/locals.h --- old/apps/tuxbox/neutrino/src/system/locals.h 2006-01-05 12:59:42.000000000 +0100 +++ new/apps/tuxbox/neutrino/src/system/locals.h 2006-01-05 11:48:57.000000000 +0100 @@ -2,7 +2,7 @@ #define __locals__ /* - * $Id: locals.h,v 1.60 2005/12/10 10:49:20 barf Exp $ + * $Id$ * * (C) 2004 by thegoodguy * @@ -1048,6 +1048,10 @@ LOCALE_VIDEOMENU_HEAD, LOCALE_VIDEOMENU_RGB_CENTERING, LOCALE_VIDEOMENU_SCREENSETUP, + LOCALE_VIDEOMENU_VCRSIGNAL, + LOCALE_VIDEOMENU_VCRSIGNAL_COMPOSITE, + LOCALE_VIDEOMENU_VCRSIGNAL_SVIDEO, + LOCALE_VIDEOMENU_VCRSIGNAL_SVIDEO_FAILURE, LOCALE_VIDEOMENU_VCRSWITCH, LOCALE_VIDEOMENU_VIDEOFORMAT, LOCALE_VIDEOMENU_VIDEOFORMAT_169, diff -Naur old/apps/tuxbox/neutrino/src/system/locals_intern.h new/apps/tuxbox/neutrino/src/system/locals_intern.h --- old/apps/tuxbox/neutrino/src/system/locals_intern.h 2006-01-05 12:59:42.000000000 +0100 +++ new/apps/tuxbox/neutrino/src/system/locals_intern.h 2006-01-05 11:48:57.000000000 +0100 @@ -2,7 +2,7 @@ #define __locals_intern__ /* - * $Id: locals_intern.h,v 1.61 2005/12/10 10:49:20 barf Exp $ + * $Id$ * * (C) 2004 by thegoodguy * @@ -1048,6 +1048,10 @@ "videomenu.head", "videomenu.rgb_centering", "videomenu.screensetup", + "videomenu.vcrsignal", + "videomenu.vcrsignal_composite", + "videomenu.vcrsignal_svideo", + "videomenu.vcrsignal_svideo_failure", "videomenu.vcrswitch", "videomenu.videoformat", "videomenu.videoformat_169", diff -Naur old/driver/saa7126/saa7126_core.c new/driver/saa7126/saa7126_core.c --- old/driver/saa7126/saa7126_core.c 2006-01-05 12:59:50.000000000 +0100 +++ new/driver/saa7126/saa7126_core.c 2005-12-17 17:03:33.000000000 +0100 @@ -348,6 +348,11 @@ return 0; } +#define REG_2D_RGB 0x0f /* RGB + CVBS (for sync) */ +#define REG_2D_FBAS 0x9e /* 10011110 */ +#define REG_2D_SVIDEO 0xbf /* 10111111 */ +#define REG_2D_YUV_V 0xcf /* reg 2D = 11001111, all DAC's on, RGB + VBS */ +#define REG_2D_YUV_C 0x8f /* reg 2D = 10001111, all DAC's on, RGB + CVBS */ static int saa7126_set_mode(struct i2c_client *client, int inp) { @@ -358,20 +363,20 @@ switch (inp) { case SAA_MODE_RGB: - encoder->reg_2d = 0x0f; /* RGB + CVBS (for sync) */ + encoder->reg_2d = REG_2D_RGB; break; case SAA_MODE_FBAS: - encoder->reg_2d = 0x08; /* 00001000 CVBS only, RGB DAC's off (high impedance mode) !!! */ + encoder->reg_2d = REG_2D_FBAS; break; case SAA_MODE_SVIDEO: - encoder->reg_2d = 0xff; /* 11111111 croma -> R, luma -> CVBS + G + B */ + encoder->reg_2d = REG_2D_SVIDEO; break; case SAA_MODE_YUV_V: - encoder->reg_2d = 0xcf; /* reg 2D = 11001111, all DAC's on, RGB + VBS */ + encoder->reg_2d = REG_2D_YUV_V; encoder->reg_3a = 0x0b; /* reg 3A = 00001011, bypass RGB-matrix */ break; case SAA_MODE_YUV_C: - encoder->reg_2d = 0x8f; /* reg 2D = 10001111, all DAC's on, RGB + CVBS */ + encoder->reg_2d = REG_2D_YUV_C; encoder->reg_3a = 0x0b; /* reg 3A = 00001011, bypass RGB-matrix */ break; default: @@ -388,18 +393,21 @@ struct saa7126 *encoder = (struct saa7126 *) client->data; switch (encoder->reg_2d) { - case 0x0f: + case REG_2D_RGB: return SAA_MODE_RGB; break; - case 0x08: +#if REG_2D_FBAS != REG_2D_SVIDEO + case REG_2D_FBAS: return SAA_MODE_FBAS; break; - case 0xff: +#endif + case REG_2D_SVIDEO: return SAA_MODE_SVIDEO; - case 0xcf: + break; + case REG_2D_YUV_V: return SAA_MODE_YUV_V; break; - case 0x8f: + case REG_2D_YUV_C: return SAA_MODE_YUV_C; break; default: