From patchwork Mon Mar 14 08:55:18 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans Petter Selasky X-Patchwork-Id: 632461 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id p2E90rCD022485 for ; Mon, 14 Mar 2011 09:00:54 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752726Ab1CNJAw (ORCPT ); Mon, 14 Mar 2011 05:00:52 -0400 Received: from mailfe04.c2i.net ([212.247.154.98]:34477 "EHLO swip.net" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752286Ab1CNJAv (ORCPT ); Mon, 14 Mar 2011 05:00:51 -0400 X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter1.kernel.org [140.211.167.41]); Mon, 14 Mar 2011 09:00:54 +0000 (UTC) X-Greylist: delayed 300 seconds by postgrey-1.27 at vger.kernel.org; Mon, 14 Mar 2011 05:00:50 EDT X-Cloudmark-Score: 0.000000 [] X-Cloudmark-Analysis: v=1.1 cv=wd7fLirDSts22yawIUsTeMUS9lsm8Llc0grT6RvpTjU= c=1 sm=1 a=YKHT1H7J0ywA:10 a=CL8lFSKtTFcA:10 a=i9M/sDlu2rpZ9XS819oYzg==:17 a=dYfcVV4EAAAA:8 a=OJ9FSXrURI2Ymo2JXy4A:9 a=W6nGSEhhVg8Cyg81D_eLbG3TLMcA:4 a=CjuIK1q_8ugA:10 a=GsovM-_vGS5CfotKvVAA:9 a=KGRZGXFU1RV3t9_SGB5MT6agV_sA:4 a=9N-la9K2kGKvzSLEe2QA:9 a=p_JSA6kuc2itKPrTbfsA:7 a=aD_IqaNspn7ZfDYWD9VP7CcgvRMA:4 a=i9M/sDlu2rpZ9XS819oYzg==:117 Received: from [188.126.198.129] (account mc467741@c2i.net HELO laptop002.hselasky.homeunix.org) by mailfe04.swip.net (CommuniGate Pro SMTP 5.2.19) with ESMTPA id 99345011; Mon, 14 Mar 2011 09:55:48 +0100 To: linux-media@vger.kernel.org Subject: Add support for [non-standard?] DiSEqC switch "MAXIMUM DiSEqC 4/1" Cc: vdr@linuxtv.org From: Hans Petter Selasky X-Face: *nPdTl_}RuAI6^PVpA02T?$%Xa^>@hE0uyUIoiha$pC:9TVgl.Oq,NwSZ4V" =?iso-8859-15?q?=7CLR=2E+tj=7Dg5=0A=09=25V?=,x^qOs~mnU3]Gn; cQLv&.N>TrxmSFf+p6(30a/{)KUU!s}w\IhQBj}[g}bj0I3^glmC( =?iso-8859-15?q?=0A=09=3AAuzV9=3A=2EhESm-x4h240C=609=3Dw?= Date: Mon, 14 Mar 2011 09:55:18 +0100 MIME-Version: 1.0 Message-Id: <201103140955.18217.hselasky@c2i.net> Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org diff -u -r --exclude='*~' work.orig/w_scan-20110206/diseqc.c work/w_scan-20110206/diseqc.c --- work.orig/w_scan-20110206/diseqc.c 2011-03-13 12:22:21.000000000 +0100 +++ work/w_scan-20110206/diseqc.c 2011-03-13 14:19:36.000000000 +0100 @@ -157,6 +157,10 @@ { { { MASTER_CMD_NO_RESPONSE, ADDR_ANY_LNB, CMD_WR_N1_UNCOMMITTED, 0xff, 0x00, 0x00 }, 4 }, 20 } }; +struct diseqc_cmd kjaerulff1_switch_cmds[] = { + { { { MASTER_CMD_NO_RESPONSE, ADDR_ANY_LNB, 0x26, 0x00, 0x00, 0x00 }, 3 }, 20 }, + { { { MASTER_CMD_NO_RESPONSE, ADDR_ANY_LNB, 0x27, 0x00, 0x00, 0x00 }, 3 }, 20 }, +}; /****************************************************************************** * only indices for positioning cmds[] - non standardized. @@ -453,6 +457,48 @@ return err; } +int setup_kjaerulff1_switch (int frontend_fd, int switch_pos, int voltage_18, int hiband) +{ + int err = 0; + int voltage = voltage_18 ? SEC_VOLTAGE_18 : SEC_VOLTAGE_13; + int tone = hiband ? SEC_TONE_ON : SEC_TONE_OFF; + int n; + + if (switch_pos < 0 || switch_pos > 3) + return (-EINVAL); + + err |= ioctl(frontend_fd, FE_SET_TONE, (int)SEC_TONE_OFF); + + for (n = 0; n != 2; n++) { + + err |= ioctl(frontend_fd, FE_SET_VOLTAGE, (int)SEC_VOLTAGE_OFF); + usleep(45000); + err |= ioctl(frontend_fd, FE_SET_VOLTAGE, voltage); + usleep(15000); + if (switch_pos == 1) + err |= ioctl(frontend_fd, FE_DISEQC_SEND_MASTER_CMD, &kjaerulff1_switch_cmds[0].cmd); + if (switch_pos == 2 || switch_pos == 3) + err |= ioctl(frontend_fd, FE_DISEQC_SEND_MASTER_CMD, &kjaerulff1_switch_cmds[1].cmd); + usleep(45000); + + if (switch_pos == 3) { + err |= ioctl(frontend_fd, FE_SET_VOLTAGE, (int)SEC_VOLTAGE_OFF); + usleep(45000); + err |= ioctl(frontend_fd, FE_SET_VOLTAGE, voltage); + usleep(15000); + err |= ioctl(frontend_fd, FE_DISEQC_SEND_MASTER_CMD, &kjaerulff1_switch_cmds[0].cmd); + usleep(45000); + } + } + + err |= ioctl(frontend_fd, FE_SET_TONE, tone); + + if (err) + return (-EINVAL); + + return (0); +} + int setup_switch (int frontend_fd, int switch_pos, int voltage_18, int hiband, int uncommitted_switch_pos) { int i; diff -u -r --exclude='*~' work.orig/w_scan-20110206/diseqc.h work/w_scan-20110206/diseqc.h --- work.orig/w_scan-20110206/diseqc.h 2011-03-13 12:22:21.000000000 +0100 +++ work/w_scan-20110206/diseqc.h 2011-03-13 12:38:18.000000000 +0100 @@ -20,6 +20,7 @@ /* * set up the switch to position/voltage/tone */ +int setup_kjaerulff1_switch (int frontend_fd, int switch_pos, int voltage_18, int hiband); int setup_switch (int frontend_fd, int switch_pos, int voltage_18, int freq, int uncommitted_switch_pos); int rotate_rotor (int frontend_fd, int * from, int to, uint8_t voltage_18, uint8_t hiband); diff -u -r --exclude='*~' work.orig/w_scan-20110206/scan.c work/w_scan-20110206/scan.c --- work.orig/w_scan-20110206/scan.c 2011-03-13 12:22:21.000000000 +0100 +++ work/w_scan-20110206/scan.c 2011-03-13 14:23:27.000000000 +0100 @@ -113,6 +113,7 @@ static int committed_switch = 0; // 20090320: DVB-S/S2, DISEQC committed switch position static int uncommitted_switch = 0; // 20090320: DVB-S/S2, DISEQC uncommitted switch position static struct lnb_types_st this_lnb; // 20090320: DVB-S/S2, LNB type, initialized in main to 'UNIVERSAL' +static int kjaerulff1_switch_pos = -1; // 20110313: Non-standard Kjaerulff1 switch type time_t start_time = 0; @@ -1619,7 +1620,12 @@ if (t->param.frequency >= this_lnb.switch_val) switch_to_high_band++; - setup_switch (frontend_fd, committed_switch, + if (kjaerulff1_switch_pos > -1) + setup_kjaerulff1_switch (frontend_fd, kjaerulff1_switch_pos, + t->param.u.qpsk.polarization == POLARIZATION_VERTICAL ? 0 : 1, + switch_to_high_band); + else + setup_switch (frontend_fd, committed_switch, t->param.u.qpsk.polarization == POLARIZATION_VERTICAL ? 0 : 1, switch_to_high_band, uncommitted_switch); @@ -2584,6 +2590,7 @@ " ? for list\n" " -D Nc use DiSEqC committed switch position N\n" " -D Nu use DiSEqC uncommitted switch position N\n" + " -K N use non-standard Kjaerulff1 switch position N\n" " -p \n" " use DiSEqC rotor Position file\n" " -r N use Rotor position N (needs -s)\n" @@ -2642,7 +2649,7 @@ flags.version = version; start_time = time(NULL); - while ((opt = getopt(argc, argv, "a:c:e:f:hi:kl:o:p:qr:s:t:vxA:D:E:FHI:LMO:PQ:R:S:T:VX")) != -1) { + while ((opt = getopt(argc, argv, "a:c:e:f:hi:kl:o:p:qr:s:t:vxA:D:E:FHI:K:LMO:PQ:R:S:T:VX")) != -1) { switch (opt) { case 'a': //adapter adapter = strtoul(optarg, NULL, 0); @@ -2682,6 +2689,11 @@ case 'k': //kaffeine output output_format = OUTPUT_KAFFEINE; break; + case 'K': + kjaerulff1_switch_pos = strtoul(optarg, NULL, 0); + if (kjaerulff1_switch_pos > 3 || kjaerulff1_switch_pos < 0) + fatal("kjaerulff1 switch position needs to be in the range [0..3]!\n"); + break; case 'l': //satellite lnb type if (strcmp(optarg, "?") == 0) { struct lnb_types_st * p; @@ -3169,6 +3181,8 @@ info("using DiSEqC committed switch %d\n", committed_switch); if (uncommitted_switch > 0) info("using DiSEqC uncommitted switch %d\n", uncommitted_switch); + if (kjaerulff1_switch_pos > -1) + info("using DiSEqC Kjaerulff1 switch %d\n", kjaerulff1_switch_pos); /* grrr... * DVB API v5 doesnt allow checking for * S2 capabilities fec3/5, fec9/10, PSK_8,