18c2ecf20Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0-or-later 28c2ecf20Sopenharmony_ci/* 38c2ecf20Sopenharmony_ci * budget-ci.c: driver for the SAA7146 based Budget DVB cards 48c2ecf20Sopenharmony_ci * 58c2ecf20Sopenharmony_ci * Compiled from various sources by Michael Hunold <michael@mihu.de> 68c2ecf20Sopenharmony_ci * 78c2ecf20Sopenharmony_ci * msp430 IR support contributed by Jack Thomasson <jkt@Helius.COM> 88c2ecf20Sopenharmony_ci * partially based on the Siemens DVB driver by Ralph+Marcus Metzler 98c2ecf20Sopenharmony_ci * 108c2ecf20Sopenharmony_ci * CI interface support (c) 2004 Andrew de Quincey <adq_dvb@lidskialf.net> 118c2ecf20Sopenharmony_ci * 128c2ecf20Sopenharmony_ci * the project's page is at https://linuxtv.org 138c2ecf20Sopenharmony_ci */ 148c2ecf20Sopenharmony_ci 158c2ecf20Sopenharmony_ci#include <linux/module.h> 168c2ecf20Sopenharmony_ci#include <linux/errno.h> 178c2ecf20Sopenharmony_ci#include <linux/slab.h> 188c2ecf20Sopenharmony_ci#include <linux/interrupt.h> 198c2ecf20Sopenharmony_ci#include <linux/spinlock.h> 208c2ecf20Sopenharmony_ci#include <media/rc-core.h> 218c2ecf20Sopenharmony_ci 228c2ecf20Sopenharmony_ci#include "budget.h" 238c2ecf20Sopenharmony_ci 248c2ecf20Sopenharmony_ci#include <media/dvb_ca_en50221.h> 258c2ecf20Sopenharmony_ci#include "stv0299.h" 268c2ecf20Sopenharmony_ci#include "stv0297.h" 278c2ecf20Sopenharmony_ci#include "tda1004x.h" 288c2ecf20Sopenharmony_ci#include "stb0899_drv.h" 298c2ecf20Sopenharmony_ci#include "stb0899_reg.h" 308c2ecf20Sopenharmony_ci#include "stb0899_cfg.h" 318c2ecf20Sopenharmony_ci#include "stb6100.h" 328c2ecf20Sopenharmony_ci#include "stb6100_cfg.h" 338c2ecf20Sopenharmony_ci#include "lnbp21.h" 348c2ecf20Sopenharmony_ci#include "bsbe1.h" 358c2ecf20Sopenharmony_ci#include "bsru6.h" 368c2ecf20Sopenharmony_ci#include "tda1002x.h" 378c2ecf20Sopenharmony_ci#include "tda827x.h" 388c2ecf20Sopenharmony_ci#include "bsbe1-d01a.h" 398c2ecf20Sopenharmony_ci 408c2ecf20Sopenharmony_ci#define MODULE_NAME "budget_ci" 418c2ecf20Sopenharmony_ci 428c2ecf20Sopenharmony_ci/* 438c2ecf20Sopenharmony_ci * Regarding DEBIADDR_IR: 448c2ecf20Sopenharmony_ci * Some CI modules hang if random addresses are read. 458c2ecf20Sopenharmony_ci * Using address 0x4000 for the IR read means that we 468c2ecf20Sopenharmony_ci * use the same address as for CI version, which should 478c2ecf20Sopenharmony_ci * be a safe default. 488c2ecf20Sopenharmony_ci */ 498c2ecf20Sopenharmony_ci#define DEBIADDR_IR 0x4000 508c2ecf20Sopenharmony_ci#define DEBIADDR_CICONTROL 0x0000 518c2ecf20Sopenharmony_ci#define DEBIADDR_CIVERSION 0x4000 528c2ecf20Sopenharmony_ci#define DEBIADDR_IO 0x1000 538c2ecf20Sopenharmony_ci#define DEBIADDR_ATTR 0x3000 548c2ecf20Sopenharmony_ci 558c2ecf20Sopenharmony_ci#define CICONTROL_RESET 0x01 568c2ecf20Sopenharmony_ci#define CICONTROL_ENABLETS 0x02 578c2ecf20Sopenharmony_ci#define CICONTROL_CAMDETECT 0x08 588c2ecf20Sopenharmony_ci 598c2ecf20Sopenharmony_ci#define DEBICICTL 0x00420000 608c2ecf20Sopenharmony_ci#define DEBICICAM 0x02420000 618c2ecf20Sopenharmony_ci 628c2ecf20Sopenharmony_ci#define SLOTSTATUS_NONE 1 638c2ecf20Sopenharmony_ci#define SLOTSTATUS_PRESENT 2 648c2ecf20Sopenharmony_ci#define SLOTSTATUS_RESET 4 658c2ecf20Sopenharmony_ci#define SLOTSTATUS_READY 8 668c2ecf20Sopenharmony_ci#define SLOTSTATUS_OCCUPIED (SLOTSTATUS_PRESENT|SLOTSTATUS_RESET|SLOTSTATUS_READY) 678c2ecf20Sopenharmony_ci 688c2ecf20Sopenharmony_ci/* RC5 device wildcard */ 698c2ecf20Sopenharmony_ci#define IR_DEVICE_ANY 255 708c2ecf20Sopenharmony_ci 718c2ecf20Sopenharmony_cistatic int rc5_device = -1; 728c2ecf20Sopenharmony_cimodule_param(rc5_device, int, 0644); 738c2ecf20Sopenharmony_ciMODULE_PARM_DESC(rc5_device, "only IR commands to given RC5 device (device = 0 - 31, any device = 255, default: autodetect)"); 748c2ecf20Sopenharmony_ci 758c2ecf20Sopenharmony_cistatic int ir_debug; 768c2ecf20Sopenharmony_cimodule_param(ir_debug, int, 0644); 778c2ecf20Sopenharmony_ciMODULE_PARM_DESC(ir_debug, "enable debugging information for IR decoding"); 788c2ecf20Sopenharmony_ci 798c2ecf20Sopenharmony_ciDVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr); 808c2ecf20Sopenharmony_ci 818c2ecf20Sopenharmony_cistruct budget_ci_ir { 828c2ecf20Sopenharmony_ci struct rc_dev *dev; 838c2ecf20Sopenharmony_ci struct tasklet_struct msp430_irq_tasklet; 848c2ecf20Sopenharmony_ci char name[72]; /* 40 + 32 for (struct saa7146_dev).name */ 858c2ecf20Sopenharmony_ci char phys[32]; 868c2ecf20Sopenharmony_ci int rc5_device; 878c2ecf20Sopenharmony_ci u32 ir_key; 888c2ecf20Sopenharmony_ci bool have_command; 898c2ecf20Sopenharmony_ci bool full_rc5; /* Outputs a full RC5 code */ 908c2ecf20Sopenharmony_ci}; 918c2ecf20Sopenharmony_ci 928c2ecf20Sopenharmony_cistruct budget_ci { 938c2ecf20Sopenharmony_ci struct budget budget; 948c2ecf20Sopenharmony_ci struct tasklet_struct ciintf_irq_tasklet; 958c2ecf20Sopenharmony_ci int slot_status; 968c2ecf20Sopenharmony_ci int ci_irq; 978c2ecf20Sopenharmony_ci struct dvb_ca_en50221 ca; 988c2ecf20Sopenharmony_ci struct budget_ci_ir ir; 998c2ecf20Sopenharmony_ci u8 tuner_pll_address; /* used for philips_tdm1316l configs */ 1008c2ecf20Sopenharmony_ci}; 1018c2ecf20Sopenharmony_ci 1028c2ecf20Sopenharmony_cistatic void msp430_ir_interrupt(struct tasklet_struct *t) 1038c2ecf20Sopenharmony_ci{ 1048c2ecf20Sopenharmony_ci struct budget_ci_ir *ir = from_tasklet(ir, t, msp430_irq_tasklet); 1058c2ecf20Sopenharmony_ci struct budget_ci *budget_ci = container_of(ir, typeof(*budget_ci), ir); 1068c2ecf20Sopenharmony_ci struct rc_dev *dev = budget_ci->ir.dev; 1078c2ecf20Sopenharmony_ci u32 command = ttpci_budget_debiread(&budget_ci->budget, DEBINOSWAP, DEBIADDR_IR, 2, 1, 0) >> 8; 1088c2ecf20Sopenharmony_ci 1098c2ecf20Sopenharmony_ci /* 1108c2ecf20Sopenharmony_ci * The msp430 chip can generate two different bytes, command and device 1118c2ecf20Sopenharmony_ci * 1128c2ecf20Sopenharmony_ci * type1: X1CCCCCC, C = command bits (0 - 63) 1138c2ecf20Sopenharmony_ci * type2: X0TDDDDD, D = device bits (0 - 31), T = RC5 toggle bit 1148c2ecf20Sopenharmony_ci * 1158c2ecf20Sopenharmony_ci * Each signal from the remote control can generate one or more command 1168c2ecf20Sopenharmony_ci * bytes and one or more device bytes. For the repeated bytes, the 1178c2ecf20Sopenharmony_ci * highest bit (X) is set. The first command byte is always generated 1188c2ecf20Sopenharmony_ci * before the first device byte. Other than that, no specific order 1198c2ecf20Sopenharmony_ci * seems to apply. To make life interesting, bytes can also be lost. 1208c2ecf20Sopenharmony_ci * 1218c2ecf20Sopenharmony_ci * Only when we have a command and device byte, a keypress is 1228c2ecf20Sopenharmony_ci * generated. 1238c2ecf20Sopenharmony_ci */ 1248c2ecf20Sopenharmony_ci 1258c2ecf20Sopenharmony_ci if (ir_debug) 1268c2ecf20Sopenharmony_ci printk("budget_ci: received byte 0x%02x\n", command); 1278c2ecf20Sopenharmony_ci 1288c2ecf20Sopenharmony_ci /* Remove repeat bit, we use every command */ 1298c2ecf20Sopenharmony_ci command = command & 0x7f; 1308c2ecf20Sopenharmony_ci 1318c2ecf20Sopenharmony_ci /* Is this a RC5 command byte? */ 1328c2ecf20Sopenharmony_ci if (command & 0x40) { 1338c2ecf20Sopenharmony_ci budget_ci->ir.have_command = true; 1348c2ecf20Sopenharmony_ci budget_ci->ir.ir_key = command & 0x3f; 1358c2ecf20Sopenharmony_ci return; 1368c2ecf20Sopenharmony_ci } 1378c2ecf20Sopenharmony_ci 1388c2ecf20Sopenharmony_ci /* It's a RC5 device byte */ 1398c2ecf20Sopenharmony_ci if (!budget_ci->ir.have_command) 1408c2ecf20Sopenharmony_ci return; 1418c2ecf20Sopenharmony_ci budget_ci->ir.have_command = false; 1428c2ecf20Sopenharmony_ci 1438c2ecf20Sopenharmony_ci if (budget_ci->ir.rc5_device != IR_DEVICE_ANY && 1448c2ecf20Sopenharmony_ci budget_ci->ir.rc5_device != (command & 0x1f)) 1458c2ecf20Sopenharmony_ci return; 1468c2ecf20Sopenharmony_ci 1478c2ecf20Sopenharmony_ci if (budget_ci->ir.full_rc5) { 1488c2ecf20Sopenharmony_ci rc_keydown(dev, RC_PROTO_RC5, 1498c2ecf20Sopenharmony_ci RC_SCANCODE_RC5(budget_ci->ir.rc5_device, budget_ci->ir.ir_key), 1508c2ecf20Sopenharmony_ci !!(command & 0x20)); 1518c2ecf20Sopenharmony_ci return; 1528c2ecf20Sopenharmony_ci } 1538c2ecf20Sopenharmony_ci 1548c2ecf20Sopenharmony_ci /* FIXME: We should generate complete scancodes for all devices */ 1558c2ecf20Sopenharmony_ci rc_keydown(dev, RC_PROTO_UNKNOWN, budget_ci->ir.ir_key, 1568c2ecf20Sopenharmony_ci !!(command & 0x20)); 1578c2ecf20Sopenharmony_ci} 1588c2ecf20Sopenharmony_ci 1598c2ecf20Sopenharmony_cistatic int msp430_ir_init(struct budget_ci *budget_ci) 1608c2ecf20Sopenharmony_ci{ 1618c2ecf20Sopenharmony_ci struct saa7146_dev *saa = budget_ci->budget.dev; 1628c2ecf20Sopenharmony_ci struct rc_dev *dev; 1638c2ecf20Sopenharmony_ci int error; 1648c2ecf20Sopenharmony_ci 1658c2ecf20Sopenharmony_ci dev = rc_allocate_device(RC_DRIVER_SCANCODE); 1668c2ecf20Sopenharmony_ci if (!dev) { 1678c2ecf20Sopenharmony_ci printk(KERN_ERR "budget_ci: IR interface initialisation failed\n"); 1688c2ecf20Sopenharmony_ci return -ENOMEM; 1698c2ecf20Sopenharmony_ci } 1708c2ecf20Sopenharmony_ci 1718c2ecf20Sopenharmony_ci snprintf(budget_ci->ir.name, sizeof(budget_ci->ir.name), 1728c2ecf20Sopenharmony_ci "Budget-CI dvb ir receiver %s", saa->name); 1738c2ecf20Sopenharmony_ci snprintf(budget_ci->ir.phys, sizeof(budget_ci->ir.phys), 1748c2ecf20Sopenharmony_ci "pci-%s/ir0", pci_name(saa->pci)); 1758c2ecf20Sopenharmony_ci 1768c2ecf20Sopenharmony_ci dev->driver_name = MODULE_NAME; 1778c2ecf20Sopenharmony_ci dev->device_name = budget_ci->ir.name; 1788c2ecf20Sopenharmony_ci dev->input_phys = budget_ci->ir.phys; 1798c2ecf20Sopenharmony_ci dev->input_id.bustype = BUS_PCI; 1808c2ecf20Sopenharmony_ci dev->input_id.version = 1; 1818c2ecf20Sopenharmony_ci if (saa->pci->subsystem_vendor) { 1828c2ecf20Sopenharmony_ci dev->input_id.vendor = saa->pci->subsystem_vendor; 1838c2ecf20Sopenharmony_ci dev->input_id.product = saa->pci->subsystem_device; 1848c2ecf20Sopenharmony_ci } else { 1858c2ecf20Sopenharmony_ci dev->input_id.vendor = saa->pci->vendor; 1868c2ecf20Sopenharmony_ci dev->input_id.product = saa->pci->device; 1878c2ecf20Sopenharmony_ci } 1888c2ecf20Sopenharmony_ci dev->dev.parent = &saa->pci->dev; 1898c2ecf20Sopenharmony_ci 1908c2ecf20Sopenharmony_ci if (rc5_device < 0) 1918c2ecf20Sopenharmony_ci budget_ci->ir.rc5_device = IR_DEVICE_ANY; 1928c2ecf20Sopenharmony_ci else 1938c2ecf20Sopenharmony_ci budget_ci->ir.rc5_device = rc5_device; 1948c2ecf20Sopenharmony_ci 1958c2ecf20Sopenharmony_ci /* Select keymap and address */ 1968c2ecf20Sopenharmony_ci switch (budget_ci->budget.dev->pci->subsystem_device) { 1978c2ecf20Sopenharmony_ci case 0x100c: 1988c2ecf20Sopenharmony_ci case 0x100f: 1998c2ecf20Sopenharmony_ci case 0x1011: 2008c2ecf20Sopenharmony_ci case 0x1012: 2018c2ecf20Sopenharmony_ci /* The hauppauge keymap is a superset of these remotes */ 2028c2ecf20Sopenharmony_ci dev->map_name = RC_MAP_HAUPPAUGE; 2038c2ecf20Sopenharmony_ci budget_ci->ir.full_rc5 = true; 2048c2ecf20Sopenharmony_ci 2058c2ecf20Sopenharmony_ci if (rc5_device < 0) 2068c2ecf20Sopenharmony_ci budget_ci->ir.rc5_device = 0x1f; 2078c2ecf20Sopenharmony_ci break; 2088c2ecf20Sopenharmony_ci case 0x1010: 2098c2ecf20Sopenharmony_ci case 0x1017: 2108c2ecf20Sopenharmony_ci case 0x1019: 2118c2ecf20Sopenharmony_ci case 0x101a: 2128c2ecf20Sopenharmony_ci case 0x101b: 2138c2ecf20Sopenharmony_ci /* for the Technotrend 1500 bundled remote */ 2148c2ecf20Sopenharmony_ci dev->map_name = RC_MAP_TT_1500; 2158c2ecf20Sopenharmony_ci break; 2168c2ecf20Sopenharmony_ci default: 2178c2ecf20Sopenharmony_ci /* unknown remote */ 2188c2ecf20Sopenharmony_ci dev->map_name = RC_MAP_BUDGET_CI_OLD; 2198c2ecf20Sopenharmony_ci break; 2208c2ecf20Sopenharmony_ci } 2218c2ecf20Sopenharmony_ci if (!budget_ci->ir.full_rc5) 2228c2ecf20Sopenharmony_ci dev->scancode_mask = 0xff; 2238c2ecf20Sopenharmony_ci 2248c2ecf20Sopenharmony_ci error = rc_register_device(dev); 2258c2ecf20Sopenharmony_ci if (error) { 2268c2ecf20Sopenharmony_ci printk(KERN_ERR "budget_ci: could not init driver for IR device (code %d)\n", error); 2278c2ecf20Sopenharmony_ci rc_free_device(dev); 2288c2ecf20Sopenharmony_ci return error; 2298c2ecf20Sopenharmony_ci } 2308c2ecf20Sopenharmony_ci 2318c2ecf20Sopenharmony_ci budget_ci->ir.dev = dev; 2328c2ecf20Sopenharmony_ci 2338c2ecf20Sopenharmony_ci tasklet_setup(&budget_ci->ir.msp430_irq_tasklet, msp430_ir_interrupt); 2348c2ecf20Sopenharmony_ci 2358c2ecf20Sopenharmony_ci SAA7146_IER_ENABLE(saa, MASK_06); 2368c2ecf20Sopenharmony_ci saa7146_setgpio(saa, 3, SAA7146_GPIO_IRQHI); 2378c2ecf20Sopenharmony_ci 2388c2ecf20Sopenharmony_ci return 0; 2398c2ecf20Sopenharmony_ci} 2408c2ecf20Sopenharmony_ci 2418c2ecf20Sopenharmony_cistatic void msp430_ir_deinit(struct budget_ci *budget_ci) 2428c2ecf20Sopenharmony_ci{ 2438c2ecf20Sopenharmony_ci struct saa7146_dev *saa = budget_ci->budget.dev; 2448c2ecf20Sopenharmony_ci 2458c2ecf20Sopenharmony_ci SAA7146_IER_DISABLE(saa, MASK_06); 2468c2ecf20Sopenharmony_ci saa7146_setgpio(saa, 3, SAA7146_GPIO_INPUT); 2478c2ecf20Sopenharmony_ci tasklet_kill(&budget_ci->ir.msp430_irq_tasklet); 2488c2ecf20Sopenharmony_ci 2498c2ecf20Sopenharmony_ci rc_unregister_device(budget_ci->ir.dev); 2508c2ecf20Sopenharmony_ci} 2518c2ecf20Sopenharmony_ci 2528c2ecf20Sopenharmony_cistatic int ciintf_read_attribute_mem(struct dvb_ca_en50221 *ca, int slot, int address) 2538c2ecf20Sopenharmony_ci{ 2548c2ecf20Sopenharmony_ci struct budget_ci *budget_ci = (struct budget_ci *) ca->data; 2558c2ecf20Sopenharmony_ci 2568c2ecf20Sopenharmony_ci if (slot != 0) 2578c2ecf20Sopenharmony_ci return -EINVAL; 2588c2ecf20Sopenharmony_ci 2598c2ecf20Sopenharmony_ci return ttpci_budget_debiread(&budget_ci->budget, DEBICICAM, 2608c2ecf20Sopenharmony_ci DEBIADDR_ATTR | (address & 0xfff), 1, 1, 0); 2618c2ecf20Sopenharmony_ci} 2628c2ecf20Sopenharmony_ci 2638c2ecf20Sopenharmony_cistatic int ciintf_write_attribute_mem(struct dvb_ca_en50221 *ca, int slot, int address, u8 value) 2648c2ecf20Sopenharmony_ci{ 2658c2ecf20Sopenharmony_ci struct budget_ci *budget_ci = (struct budget_ci *) ca->data; 2668c2ecf20Sopenharmony_ci 2678c2ecf20Sopenharmony_ci if (slot != 0) 2688c2ecf20Sopenharmony_ci return -EINVAL; 2698c2ecf20Sopenharmony_ci 2708c2ecf20Sopenharmony_ci return ttpci_budget_debiwrite(&budget_ci->budget, DEBICICAM, 2718c2ecf20Sopenharmony_ci DEBIADDR_ATTR | (address & 0xfff), 1, value, 1, 0); 2728c2ecf20Sopenharmony_ci} 2738c2ecf20Sopenharmony_ci 2748c2ecf20Sopenharmony_cistatic int ciintf_read_cam_control(struct dvb_ca_en50221 *ca, int slot, u8 address) 2758c2ecf20Sopenharmony_ci{ 2768c2ecf20Sopenharmony_ci struct budget_ci *budget_ci = (struct budget_ci *) ca->data; 2778c2ecf20Sopenharmony_ci 2788c2ecf20Sopenharmony_ci if (slot != 0) 2798c2ecf20Sopenharmony_ci return -EINVAL; 2808c2ecf20Sopenharmony_ci 2818c2ecf20Sopenharmony_ci return ttpci_budget_debiread(&budget_ci->budget, DEBICICAM, 2828c2ecf20Sopenharmony_ci DEBIADDR_IO | (address & 3), 1, 1, 0); 2838c2ecf20Sopenharmony_ci} 2848c2ecf20Sopenharmony_ci 2858c2ecf20Sopenharmony_cistatic int ciintf_write_cam_control(struct dvb_ca_en50221 *ca, int slot, u8 address, u8 value) 2868c2ecf20Sopenharmony_ci{ 2878c2ecf20Sopenharmony_ci struct budget_ci *budget_ci = (struct budget_ci *) ca->data; 2888c2ecf20Sopenharmony_ci 2898c2ecf20Sopenharmony_ci if (slot != 0) 2908c2ecf20Sopenharmony_ci return -EINVAL; 2918c2ecf20Sopenharmony_ci 2928c2ecf20Sopenharmony_ci return ttpci_budget_debiwrite(&budget_ci->budget, DEBICICAM, 2938c2ecf20Sopenharmony_ci DEBIADDR_IO | (address & 3), 1, value, 1, 0); 2948c2ecf20Sopenharmony_ci} 2958c2ecf20Sopenharmony_ci 2968c2ecf20Sopenharmony_cistatic int ciintf_slot_reset(struct dvb_ca_en50221 *ca, int slot) 2978c2ecf20Sopenharmony_ci{ 2988c2ecf20Sopenharmony_ci struct budget_ci *budget_ci = (struct budget_ci *) ca->data; 2998c2ecf20Sopenharmony_ci struct saa7146_dev *saa = budget_ci->budget.dev; 3008c2ecf20Sopenharmony_ci 3018c2ecf20Sopenharmony_ci if (slot != 0) 3028c2ecf20Sopenharmony_ci return -EINVAL; 3038c2ecf20Sopenharmony_ci 3048c2ecf20Sopenharmony_ci if (budget_ci->ci_irq) { 3058c2ecf20Sopenharmony_ci // trigger on RISING edge during reset so we know when READY is re-asserted 3068c2ecf20Sopenharmony_ci saa7146_setgpio(saa, 0, SAA7146_GPIO_IRQHI); 3078c2ecf20Sopenharmony_ci } 3088c2ecf20Sopenharmony_ci budget_ci->slot_status = SLOTSTATUS_RESET; 3098c2ecf20Sopenharmony_ci ttpci_budget_debiwrite(&budget_ci->budget, DEBICICTL, DEBIADDR_CICONTROL, 1, 0, 1, 0); 3108c2ecf20Sopenharmony_ci msleep(1); 3118c2ecf20Sopenharmony_ci ttpci_budget_debiwrite(&budget_ci->budget, DEBICICTL, DEBIADDR_CICONTROL, 1, 3128c2ecf20Sopenharmony_ci CICONTROL_RESET, 1, 0); 3138c2ecf20Sopenharmony_ci 3148c2ecf20Sopenharmony_ci saa7146_setgpio(saa, 1, SAA7146_GPIO_OUTHI); 3158c2ecf20Sopenharmony_ci ttpci_budget_set_video_port(saa, BUDGET_VIDEO_PORTB); 3168c2ecf20Sopenharmony_ci return 0; 3178c2ecf20Sopenharmony_ci} 3188c2ecf20Sopenharmony_ci 3198c2ecf20Sopenharmony_cistatic int ciintf_slot_shutdown(struct dvb_ca_en50221 *ca, int slot) 3208c2ecf20Sopenharmony_ci{ 3218c2ecf20Sopenharmony_ci struct budget_ci *budget_ci = (struct budget_ci *) ca->data; 3228c2ecf20Sopenharmony_ci struct saa7146_dev *saa = budget_ci->budget.dev; 3238c2ecf20Sopenharmony_ci 3248c2ecf20Sopenharmony_ci if (slot != 0) 3258c2ecf20Sopenharmony_ci return -EINVAL; 3268c2ecf20Sopenharmony_ci 3278c2ecf20Sopenharmony_ci saa7146_setgpio(saa, 1, SAA7146_GPIO_OUTHI); 3288c2ecf20Sopenharmony_ci ttpci_budget_set_video_port(saa, BUDGET_VIDEO_PORTB); 3298c2ecf20Sopenharmony_ci return 0; 3308c2ecf20Sopenharmony_ci} 3318c2ecf20Sopenharmony_ci 3328c2ecf20Sopenharmony_cistatic int ciintf_slot_ts_enable(struct dvb_ca_en50221 *ca, int slot) 3338c2ecf20Sopenharmony_ci{ 3348c2ecf20Sopenharmony_ci struct budget_ci *budget_ci = (struct budget_ci *) ca->data; 3358c2ecf20Sopenharmony_ci struct saa7146_dev *saa = budget_ci->budget.dev; 3368c2ecf20Sopenharmony_ci int tmp; 3378c2ecf20Sopenharmony_ci 3388c2ecf20Sopenharmony_ci if (slot != 0) 3398c2ecf20Sopenharmony_ci return -EINVAL; 3408c2ecf20Sopenharmony_ci 3418c2ecf20Sopenharmony_ci saa7146_setgpio(saa, 1, SAA7146_GPIO_OUTLO); 3428c2ecf20Sopenharmony_ci 3438c2ecf20Sopenharmony_ci tmp = ttpci_budget_debiread(&budget_ci->budget, DEBICICTL, DEBIADDR_CICONTROL, 1, 1, 0); 3448c2ecf20Sopenharmony_ci ttpci_budget_debiwrite(&budget_ci->budget, DEBICICTL, DEBIADDR_CICONTROL, 1, 3458c2ecf20Sopenharmony_ci tmp | CICONTROL_ENABLETS, 1, 0); 3468c2ecf20Sopenharmony_ci 3478c2ecf20Sopenharmony_ci ttpci_budget_set_video_port(saa, BUDGET_VIDEO_PORTA); 3488c2ecf20Sopenharmony_ci return 0; 3498c2ecf20Sopenharmony_ci} 3508c2ecf20Sopenharmony_ci 3518c2ecf20Sopenharmony_cistatic void ciintf_interrupt(struct tasklet_struct *t) 3528c2ecf20Sopenharmony_ci{ 3538c2ecf20Sopenharmony_ci struct budget_ci *budget_ci = from_tasklet(budget_ci, t, 3548c2ecf20Sopenharmony_ci ciintf_irq_tasklet); 3558c2ecf20Sopenharmony_ci struct saa7146_dev *saa = budget_ci->budget.dev; 3568c2ecf20Sopenharmony_ci unsigned int flags; 3578c2ecf20Sopenharmony_ci 3588c2ecf20Sopenharmony_ci // ensure we don't get spurious IRQs during initialisation 3598c2ecf20Sopenharmony_ci if (!budget_ci->budget.ci_present) 3608c2ecf20Sopenharmony_ci return; 3618c2ecf20Sopenharmony_ci 3628c2ecf20Sopenharmony_ci // read the CAM status 3638c2ecf20Sopenharmony_ci flags = ttpci_budget_debiread(&budget_ci->budget, DEBICICTL, DEBIADDR_CICONTROL, 1, 1, 0); 3648c2ecf20Sopenharmony_ci if (flags & CICONTROL_CAMDETECT) { 3658c2ecf20Sopenharmony_ci 3668c2ecf20Sopenharmony_ci // GPIO should be set to trigger on falling edge if a CAM is present 3678c2ecf20Sopenharmony_ci saa7146_setgpio(saa, 0, SAA7146_GPIO_IRQLO); 3688c2ecf20Sopenharmony_ci 3698c2ecf20Sopenharmony_ci if (budget_ci->slot_status & SLOTSTATUS_NONE) { 3708c2ecf20Sopenharmony_ci // CAM insertion IRQ 3718c2ecf20Sopenharmony_ci budget_ci->slot_status = SLOTSTATUS_PRESENT; 3728c2ecf20Sopenharmony_ci dvb_ca_en50221_camchange_irq(&budget_ci->ca, 0, 3738c2ecf20Sopenharmony_ci DVB_CA_EN50221_CAMCHANGE_INSERTED); 3748c2ecf20Sopenharmony_ci 3758c2ecf20Sopenharmony_ci } else if (budget_ci->slot_status & SLOTSTATUS_RESET) { 3768c2ecf20Sopenharmony_ci // CAM ready (reset completed) 3778c2ecf20Sopenharmony_ci budget_ci->slot_status = SLOTSTATUS_READY; 3788c2ecf20Sopenharmony_ci dvb_ca_en50221_camready_irq(&budget_ci->ca, 0); 3798c2ecf20Sopenharmony_ci 3808c2ecf20Sopenharmony_ci } else if (budget_ci->slot_status & SLOTSTATUS_READY) { 3818c2ecf20Sopenharmony_ci // FR/DA IRQ 3828c2ecf20Sopenharmony_ci dvb_ca_en50221_frda_irq(&budget_ci->ca, 0); 3838c2ecf20Sopenharmony_ci } 3848c2ecf20Sopenharmony_ci } else { 3858c2ecf20Sopenharmony_ci 3868c2ecf20Sopenharmony_ci // trigger on rising edge if a CAM is not present - when a CAM is inserted, we 3878c2ecf20Sopenharmony_ci // only want to get the IRQ when it sets READY. If we trigger on the falling edge, 3888c2ecf20Sopenharmony_ci // the CAM might not actually be ready yet. 3898c2ecf20Sopenharmony_ci saa7146_setgpio(saa, 0, SAA7146_GPIO_IRQHI); 3908c2ecf20Sopenharmony_ci 3918c2ecf20Sopenharmony_ci // generate a CAM removal IRQ if we haven't already 3928c2ecf20Sopenharmony_ci if (budget_ci->slot_status & SLOTSTATUS_OCCUPIED) { 3938c2ecf20Sopenharmony_ci // CAM removal IRQ 3948c2ecf20Sopenharmony_ci budget_ci->slot_status = SLOTSTATUS_NONE; 3958c2ecf20Sopenharmony_ci dvb_ca_en50221_camchange_irq(&budget_ci->ca, 0, 3968c2ecf20Sopenharmony_ci DVB_CA_EN50221_CAMCHANGE_REMOVED); 3978c2ecf20Sopenharmony_ci } 3988c2ecf20Sopenharmony_ci } 3998c2ecf20Sopenharmony_ci} 4008c2ecf20Sopenharmony_ci 4018c2ecf20Sopenharmony_cistatic int ciintf_poll_slot_status(struct dvb_ca_en50221 *ca, int slot, int open) 4028c2ecf20Sopenharmony_ci{ 4038c2ecf20Sopenharmony_ci struct budget_ci *budget_ci = (struct budget_ci *) ca->data; 4048c2ecf20Sopenharmony_ci unsigned int flags; 4058c2ecf20Sopenharmony_ci 4068c2ecf20Sopenharmony_ci // ensure we don't get spurious IRQs during initialisation 4078c2ecf20Sopenharmony_ci if (!budget_ci->budget.ci_present) 4088c2ecf20Sopenharmony_ci return -EINVAL; 4098c2ecf20Sopenharmony_ci 4108c2ecf20Sopenharmony_ci // read the CAM status 4118c2ecf20Sopenharmony_ci flags = ttpci_budget_debiread(&budget_ci->budget, DEBICICTL, DEBIADDR_CICONTROL, 1, 1, 0); 4128c2ecf20Sopenharmony_ci if (flags & CICONTROL_CAMDETECT) { 4138c2ecf20Sopenharmony_ci // mark it as present if it wasn't before 4148c2ecf20Sopenharmony_ci if (budget_ci->slot_status & SLOTSTATUS_NONE) { 4158c2ecf20Sopenharmony_ci budget_ci->slot_status = SLOTSTATUS_PRESENT; 4168c2ecf20Sopenharmony_ci } 4178c2ecf20Sopenharmony_ci 4188c2ecf20Sopenharmony_ci // during a RESET, we check if we can read from IO memory to see when CAM is ready 4198c2ecf20Sopenharmony_ci if (budget_ci->slot_status & SLOTSTATUS_RESET) { 4208c2ecf20Sopenharmony_ci if (ciintf_read_attribute_mem(ca, slot, 0) == 0x1d) { 4218c2ecf20Sopenharmony_ci budget_ci->slot_status = SLOTSTATUS_READY; 4228c2ecf20Sopenharmony_ci } 4238c2ecf20Sopenharmony_ci } 4248c2ecf20Sopenharmony_ci } else { 4258c2ecf20Sopenharmony_ci budget_ci->slot_status = SLOTSTATUS_NONE; 4268c2ecf20Sopenharmony_ci } 4278c2ecf20Sopenharmony_ci 4288c2ecf20Sopenharmony_ci if (budget_ci->slot_status != SLOTSTATUS_NONE) { 4298c2ecf20Sopenharmony_ci if (budget_ci->slot_status & SLOTSTATUS_READY) { 4308c2ecf20Sopenharmony_ci return DVB_CA_EN50221_POLL_CAM_PRESENT | DVB_CA_EN50221_POLL_CAM_READY; 4318c2ecf20Sopenharmony_ci } 4328c2ecf20Sopenharmony_ci return DVB_CA_EN50221_POLL_CAM_PRESENT; 4338c2ecf20Sopenharmony_ci } 4348c2ecf20Sopenharmony_ci 4358c2ecf20Sopenharmony_ci return 0; 4368c2ecf20Sopenharmony_ci} 4378c2ecf20Sopenharmony_ci 4388c2ecf20Sopenharmony_cistatic int ciintf_init(struct budget_ci *budget_ci) 4398c2ecf20Sopenharmony_ci{ 4408c2ecf20Sopenharmony_ci struct saa7146_dev *saa = budget_ci->budget.dev; 4418c2ecf20Sopenharmony_ci int flags; 4428c2ecf20Sopenharmony_ci int result; 4438c2ecf20Sopenharmony_ci int ci_version; 4448c2ecf20Sopenharmony_ci int ca_flags; 4458c2ecf20Sopenharmony_ci 4468c2ecf20Sopenharmony_ci memset(&budget_ci->ca, 0, sizeof(struct dvb_ca_en50221)); 4478c2ecf20Sopenharmony_ci 4488c2ecf20Sopenharmony_ci // enable DEBI pins 4498c2ecf20Sopenharmony_ci saa7146_write(saa, MC1, MASK_27 | MASK_11); 4508c2ecf20Sopenharmony_ci 4518c2ecf20Sopenharmony_ci // test if it is there 4528c2ecf20Sopenharmony_ci ci_version = ttpci_budget_debiread(&budget_ci->budget, DEBICICTL, DEBIADDR_CIVERSION, 1, 1, 0); 4538c2ecf20Sopenharmony_ci if ((ci_version & 0xa0) != 0xa0) { 4548c2ecf20Sopenharmony_ci result = -ENODEV; 4558c2ecf20Sopenharmony_ci goto error; 4568c2ecf20Sopenharmony_ci } 4578c2ecf20Sopenharmony_ci 4588c2ecf20Sopenharmony_ci // determine whether a CAM is present or not 4598c2ecf20Sopenharmony_ci flags = ttpci_budget_debiread(&budget_ci->budget, DEBICICTL, DEBIADDR_CICONTROL, 1, 1, 0); 4608c2ecf20Sopenharmony_ci budget_ci->slot_status = SLOTSTATUS_NONE; 4618c2ecf20Sopenharmony_ci if (flags & CICONTROL_CAMDETECT) 4628c2ecf20Sopenharmony_ci budget_ci->slot_status = SLOTSTATUS_PRESENT; 4638c2ecf20Sopenharmony_ci 4648c2ecf20Sopenharmony_ci // version 0xa2 of the CI firmware doesn't generate interrupts 4658c2ecf20Sopenharmony_ci if (ci_version == 0xa2) { 4668c2ecf20Sopenharmony_ci ca_flags = 0; 4678c2ecf20Sopenharmony_ci budget_ci->ci_irq = 0; 4688c2ecf20Sopenharmony_ci } else { 4698c2ecf20Sopenharmony_ci ca_flags = DVB_CA_EN50221_FLAG_IRQ_CAMCHANGE | 4708c2ecf20Sopenharmony_ci DVB_CA_EN50221_FLAG_IRQ_FR | 4718c2ecf20Sopenharmony_ci DVB_CA_EN50221_FLAG_IRQ_DA; 4728c2ecf20Sopenharmony_ci budget_ci->ci_irq = 1; 4738c2ecf20Sopenharmony_ci } 4748c2ecf20Sopenharmony_ci 4758c2ecf20Sopenharmony_ci // register CI interface 4768c2ecf20Sopenharmony_ci budget_ci->ca.owner = THIS_MODULE; 4778c2ecf20Sopenharmony_ci budget_ci->ca.read_attribute_mem = ciintf_read_attribute_mem; 4788c2ecf20Sopenharmony_ci budget_ci->ca.write_attribute_mem = ciintf_write_attribute_mem; 4798c2ecf20Sopenharmony_ci budget_ci->ca.read_cam_control = ciintf_read_cam_control; 4808c2ecf20Sopenharmony_ci budget_ci->ca.write_cam_control = ciintf_write_cam_control; 4818c2ecf20Sopenharmony_ci budget_ci->ca.slot_reset = ciintf_slot_reset; 4828c2ecf20Sopenharmony_ci budget_ci->ca.slot_shutdown = ciintf_slot_shutdown; 4838c2ecf20Sopenharmony_ci budget_ci->ca.slot_ts_enable = ciintf_slot_ts_enable; 4848c2ecf20Sopenharmony_ci budget_ci->ca.poll_slot_status = ciintf_poll_slot_status; 4858c2ecf20Sopenharmony_ci budget_ci->ca.data = budget_ci; 4868c2ecf20Sopenharmony_ci if ((result = dvb_ca_en50221_init(&budget_ci->budget.dvb_adapter, 4878c2ecf20Sopenharmony_ci &budget_ci->ca, 4888c2ecf20Sopenharmony_ci ca_flags, 1)) != 0) { 4898c2ecf20Sopenharmony_ci printk("budget_ci: CI interface detected, but initialisation failed.\n"); 4908c2ecf20Sopenharmony_ci goto error; 4918c2ecf20Sopenharmony_ci } 4928c2ecf20Sopenharmony_ci 4938c2ecf20Sopenharmony_ci // Setup CI slot IRQ 4948c2ecf20Sopenharmony_ci if (budget_ci->ci_irq) { 4958c2ecf20Sopenharmony_ci tasklet_setup(&budget_ci->ciintf_irq_tasklet, ciintf_interrupt); 4968c2ecf20Sopenharmony_ci if (budget_ci->slot_status != SLOTSTATUS_NONE) { 4978c2ecf20Sopenharmony_ci saa7146_setgpio(saa, 0, SAA7146_GPIO_IRQLO); 4988c2ecf20Sopenharmony_ci } else { 4998c2ecf20Sopenharmony_ci saa7146_setgpio(saa, 0, SAA7146_GPIO_IRQHI); 5008c2ecf20Sopenharmony_ci } 5018c2ecf20Sopenharmony_ci SAA7146_IER_ENABLE(saa, MASK_03); 5028c2ecf20Sopenharmony_ci } 5038c2ecf20Sopenharmony_ci 5048c2ecf20Sopenharmony_ci // enable interface 5058c2ecf20Sopenharmony_ci ttpci_budget_debiwrite(&budget_ci->budget, DEBICICTL, DEBIADDR_CICONTROL, 1, 5068c2ecf20Sopenharmony_ci CICONTROL_RESET, 1, 0); 5078c2ecf20Sopenharmony_ci 5088c2ecf20Sopenharmony_ci // success! 5098c2ecf20Sopenharmony_ci printk("budget_ci: CI interface initialised\n"); 5108c2ecf20Sopenharmony_ci budget_ci->budget.ci_present = 1; 5118c2ecf20Sopenharmony_ci 5128c2ecf20Sopenharmony_ci // forge a fake CI IRQ so the CAM state is setup correctly 5138c2ecf20Sopenharmony_ci if (budget_ci->ci_irq) { 5148c2ecf20Sopenharmony_ci flags = DVB_CA_EN50221_CAMCHANGE_REMOVED; 5158c2ecf20Sopenharmony_ci if (budget_ci->slot_status != SLOTSTATUS_NONE) 5168c2ecf20Sopenharmony_ci flags = DVB_CA_EN50221_CAMCHANGE_INSERTED; 5178c2ecf20Sopenharmony_ci dvb_ca_en50221_camchange_irq(&budget_ci->ca, 0, flags); 5188c2ecf20Sopenharmony_ci } 5198c2ecf20Sopenharmony_ci 5208c2ecf20Sopenharmony_ci return 0; 5218c2ecf20Sopenharmony_ci 5228c2ecf20Sopenharmony_cierror: 5238c2ecf20Sopenharmony_ci saa7146_write(saa, MC1, MASK_27); 5248c2ecf20Sopenharmony_ci return result; 5258c2ecf20Sopenharmony_ci} 5268c2ecf20Sopenharmony_ci 5278c2ecf20Sopenharmony_cistatic void ciintf_deinit(struct budget_ci *budget_ci) 5288c2ecf20Sopenharmony_ci{ 5298c2ecf20Sopenharmony_ci struct saa7146_dev *saa = budget_ci->budget.dev; 5308c2ecf20Sopenharmony_ci 5318c2ecf20Sopenharmony_ci // disable CI interrupts 5328c2ecf20Sopenharmony_ci if (budget_ci->ci_irq) { 5338c2ecf20Sopenharmony_ci SAA7146_IER_DISABLE(saa, MASK_03); 5348c2ecf20Sopenharmony_ci saa7146_setgpio(saa, 0, SAA7146_GPIO_INPUT); 5358c2ecf20Sopenharmony_ci tasklet_kill(&budget_ci->ciintf_irq_tasklet); 5368c2ecf20Sopenharmony_ci } 5378c2ecf20Sopenharmony_ci 5388c2ecf20Sopenharmony_ci // reset interface 5398c2ecf20Sopenharmony_ci ttpci_budget_debiwrite(&budget_ci->budget, DEBICICTL, DEBIADDR_CICONTROL, 1, 0, 1, 0); 5408c2ecf20Sopenharmony_ci msleep(1); 5418c2ecf20Sopenharmony_ci ttpci_budget_debiwrite(&budget_ci->budget, DEBICICTL, DEBIADDR_CICONTROL, 1, 5428c2ecf20Sopenharmony_ci CICONTROL_RESET, 1, 0); 5438c2ecf20Sopenharmony_ci 5448c2ecf20Sopenharmony_ci // disable TS data stream to CI interface 5458c2ecf20Sopenharmony_ci saa7146_setgpio(saa, 1, SAA7146_GPIO_INPUT); 5468c2ecf20Sopenharmony_ci 5478c2ecf20Sopenharmony_ci // release the CA device 5488c2ecf20Sopenharmony_ci dvb_ca_en50221_release(&budget_ci->ca); 5498c2ecf20Sopenharmony_ci 5508c2ecf20Sopenharmony_ci // disable DEBI pins 5518c2ecf20Sopenharmony_ci saa7146_write(saa, MC1, MASK_27); 5528c2ecf20Sopenharmony_ci} 5538c2ecf20Sopenharmony_ci 5548c2ecf20Sopenharmony_cistatic void budget_ci_irq(struct saa7146_dev *dev, u32 * isr) 5558c2ecf20Sopenharmony_ci{ 5568c2ecf20Sopenharmony_ci struct budget_ci *budget_ci = (struct budget_ci *) dev->ext_priv; 5578c2ecf20Sopenharmony_ci 5588c2ecf20Sopenharmony_ci dprintk(8, "dev: %p, budget_ci: %p\n", dev, budget_ci); 5598c2ecf20Sopenharmony_ci 5608c2ecf20Sopenharmony_ci if (*isr & MASK_06) 5618c2ecf20Sopenharmony_ci tasklet_schedule(&budget_ci->ir.msp430_irq_tasklet); 5628c2ecf20Sopenharmony_ci 5638c2ecf20Sopenharmony_ci if (*isr & MASK_10) 5648c2ecf20Sopenharmony_ci ttpci_budget_irq10_handler(dev, isr); 5658c2ecf20Sopenharmony_ci 5668c2ecf20Sopenharmony_ci if ((*isr & MASK_03) && (budget_ci->budget.ci_present) && (budget_ci->ci_irq)) 5678c2ecf20Sopenharmony_ci tasklet_schedule(&budget_ci->ciintf_irq_tasklet); 5688c2ecf20Sopenharmony_ci} 5698c2ecf20Sopenharmony_ci 5708c2ecf20Sopenharmony_cistatic u8 philips_su1278_tt_inittab[] = { 5718c2ecf20Sopenharmony_ci 0x01, 0x0f, 5728c2ecf20Sopenharmony_ci 0x02, 0x30, 5738c2ecf20Sopenharmony_ci 0x03, 0x00, 5748c2ecf20Sopenharmony_ci 0x04, 0x5b, 5758c2ecf20Sopenharmony_ci 0x05, 0x85, 5768c2ecf20Sopenharmony_ci 0x06, 0x02, 5778c2ecf20Sopenharmony_ci 0x07, 0x00, 5788c2ecf20Sopenharmony_ci 0x08, 0x02, 5798c2ecf20Sopenharmony_ci 0x09, 0x00, 5808c2ecf20Sopenharmony_ci 0x0C, 0x01, 5818c2ecf20Sopenharmony_ci 0x0D, 0x81, 5828c2ecf20Sopenharmony_ci 0x0E, 0x44, 5838c2ecf20Sopenharmony_ci 0x0f, 0x14, 5848c2ecf20Sopenharmony_ci 0x10, 0x3c, 5858c2ecf20Sopenharmony_ci 0x11, 0x84, 5868c2ecf20Sopenharmony_ci 0x12, 0xda, 5878c2ecf20Sopenharmony_ci 0x13, 0x97, 5888c2ecf20Sopenharmony_ci 0x14, 0x95, 5898c2ecf20Sopenharmony_ci 0x15, 0xc9, 5908c2ecf20Sopenharmony_ci 0x16, 0x19, 5918c2ecf20Sopenharmony_ci 0x17, 0x8c, 5928c2ecf20Sopenharmony_ci 0x18, 0x59, 5938c2ecf20Sopenharmony_ci 0x19, 0xf8, 5948c2ecf20Sopenharmony_ci 0x1a, 0xfe, 5958c2ecf20Sopenharmony_ci 0x1c, 0x7f, 5968c2ecf20Sopenharmony_ci 0x1d, 0x00, 5978c2ecf20Sopenharmony_ci 0x1e, 0x00, 5988c2ecf20Sopenharmony_ci 0x1f, 0x50, 5998c2ecf20Sopenharmony_ci 0x20, 0x00, 6008c2ecf20Sopenharmony_ci 0x21, 0x00, 6018c2ecf20Sopenharmony_ci 0x22, 0x00, 6028c2ecf20Sopenharmony_ci 0x23, 0x00, 6038c2ecf20Sopenharmony_ci 0x28, 0x00, 6048c2ecf20Sopenharmony_ci 0x29, 0x28, 6058c2ecf20Sopenharmony_ci 0x2a, 0x14, 6068c2ecf20Sopenharmony_ci 0x2b, 0x0f, 6078c2ecf20Sopenharmony_ci 0x2c, 0x09, 6088c2ecf20Sopenharmony_ci 0x2d, 0x09, 6098c2ecf20Sopenharmony_ci 0x31, 0x1f, 6108c2ecf20Sopenharmony_ci 0x32, 0x19, 6118c2ecf20Sopenharmony_ci 0x33, 0xfc, 6128c2ecf20Sopenharmony_ci 0x34, 0x93, 6138c2ecf20Sopenharmony_ci 0xff, 0xff 6148c2ecf20Sopenharmony_ci}; 6158c2ecf20Sopenharmony_ci 6168c2ecf20Sopenharmony_cistatic int philips_su1278_tt_set_symbol_rate(struct dvb_frontend *fe, u32 srate, u32 ratio) 6178c2ecf20Sopenharmony_ci{ 6188c2ecf20Sopenharmony_ci stv0299_writereg(fe, 0x0e, 0x44); 6198c2ecf20Sopenharmony_ci if (srate >= 10000000) { 6208c2ecf20Sopenharmony_ci stv0299_writereg(fe, 0x13, 0x97); 6218c2ecf20Sopenharmony_ci stv0299_writereg(fe, 0x14, 0x95); 6228c2ecf20Sopenharmony_ci stv0299_writereg(fe, 0x15, 0xc9); 6238c2ecf20Sopenharmony_ci stv0299_writereg(fe, 0x17, 0x8c); 6248c2ecf20Sopenharmony_ci stv0299_writereg(fe, 0x1a, 0xfe); 6258c2ecf20Sopenharmony_ci stv0299_writereg(fe, 0x1c, 0x7f); 6268c2ecf20Sopenharmony_ci stv0299_writereg(fe, 0x2d, 0x09); 6278c2ecf20Sopenharmony_ci } else { 6288c2ecf20Sopenharmony_ci stv0299_writereg(fe, 0x13, 0x99); 6298c2ecf20Sopenharmony_ci stv0299_writereg(fe, 0x14, 0x8d); 6308c2ecf20Sopenharmony_ci stv0299_writereg(fe, 0x15, 0xce); 6318c2ecf20Sopenharmony_ci stv0299_writereg(fe, 0x17, 0x43); 6328c2ecf20Sopenharmony_ci stv0299_writereg(fe, 0x1a, 0x1d); 6338c2ecf20Sopenharmony_ci stv0299_writereg(fe, 0x1c, 0x12); 6348c2ecf20Sopenharmony_ci stv0299_writereg(fe, 0x2d, 0x05); 6358c2ecf20Sopenharmony_ci } 6368c2ecf20Sopenharmony_ci stv0299_writereg(fe, 0x0e, 0x23); 6378c2ecf20Sopenharmony_ci stv0299_writereg(fe, 0x0f, 0x94); 6388c2ecf20Sopenharmony_ci stv0299_writereg(fe, 0x10, 0x39); 6398c2ecf20Sopenharmony_ci stv0299_writereg(fe, 0x15, 0xc9); 6408c2ecf20Sopenharmony_ci 6418c2ecf20Sopenharmony_ci stv0299_writereg(fe, 0x1f, (ratio >> 16) & 0xff); 6428c2ecf20Sopenharmony_ci stv0299_writereg(fe, 0x20, (ratio >> 8) & 0xff); 6438c2ecf20Sopenharmony_ci stv0299_writereg(fe, 0x21, (ratio) & 0xf0); 6448c2ecf20Sopenharmony_ci 6458c2ecf20Sopenharmony_ci return 0; 6468c2ecf20Sopenharmony_ci} 6478c2ecf20Sopenharmony_ci 6488c2ecf20Sopenharmony_cistatic int philips_su1278_tt_tuner_set_params(struct dvb_frontend *fe) 6498c2ecf20Sopenharmony_ci{ 6508c2ecf20Sopenharmony_ci struct dtv_frontend_properties *p = &fe->dtv_property_cache; 6518c2ecf20Sopenharmony_ci struct budget_ci *budget_ci = (struct budget_ci *) fe->dvb->priv; 6528c2ecf20Sopenharmony_ci u32 div; 6538c2ecf20Sopenharmony_ci u8 buf[4]; 6548c2ecf20Sopenharmony_ci struct i2c_msg msg = {.addr = 0x60,.flags = 0,.buf = buf,.len = sizeof(buf) }; 6558c2ecf20Sopenharmony_ci 6568c2ecf20Sopenharmony_ci if ((p->frequency < 950000) || (p->frequency > 2150000)) 6578c2ecf20Sopenharmony_ci return -EINVAL; 6588c2ecf20Sopenharmony_ci 6598c2ecf20Sopenharmony_ci div = (p->frequency + (500 - 1)) / 500; /* round correctly */ 6608c2ecf20Sopenharmony_ci buf[0] = (div >> 8) & 0x7f; 6618c2ecf20Sopenharmony_ci buf[1] = div & 0xff; 6628c2ecf20Sopenharmony_ci buf[2] = 0x80 | ((div & 0x18000) >> 10) | 2; 6638c2ecf20Sopenharmony_ci buf[3] = 0x20; 6648c2ecf20Sopenharmony_ci 6658c2ecf20Sopenharmony_ci if (p->symbol_rate < 4000000) 6668c2ecf20Sopenharmony_ci buf[3] |= 1; 6678c2ecf20Sopenharmony_ci 6688c2ecf20Sopenharmony_ci if (p->frequency < 1250000) 6698c2ecf20Sopenharmony_ci buf[3] |= 0; 6708c2ecf20Sopenharmony_ci else if (p->frequency < 1550000) 6718c2ecf20Sopenharmony_ci buf[3] |= 0x40; 6728c2ecf20Sopenharmony_ci else if (p->frequency < 2050000) 6738c2ecf20Sopenharmony_ci buf[3] |= 0x80; 6748c2ecf20Sopenharmony_ci else if (p->frequency < 2150000) 6758c2ecf20Sopenharmony_ci buf[3] |= 0xC0; 6768c2ecf20Sopenharmony_ci 6778c2ecf20Sopenharmony_ci if (fe->ops.i2c_gate_ctrl) 6788c2ecf20Sopenharmony_ci fe->ops.i2c_gate_ctrl(fe, 1); 6798c2ecf20Sopenharmony_ci if (i2c_transfer(&budget_ci->budget.i2c_adap, &msg, 1) != 1) 6808c2ecf20Sopenharmony_ci return -EIO; 6818c2ecf20Sopenharmony_ci return 0; 6828c2ecf20Sopenharmony_ci} 6838c2ecf20Sopenharmony_ci 6848c2ecf20Sopenharmony_cistatic const struct stv0299_config philips_su1278_tt_config = { 6858c2ecf20Sopenharmony_ci 6868c2ecf20Sopenharmony_ci .demod_address = 0x68, 6878c2ecf20Sopenharmony_ci .inittab = philips_su1278_tt_inittab, 6888c2ecf20Sopenharmony_ci .mclk = 64000000UL, 6898c2ecf20Sopenharmony_ci .invert = 0, 6908c2ecf20Sopenharmony_ci .skip_reinit = 1, 6918c2ecf20Sopenharmony_ci .lock_output = STV0299_LOCKOUTPUT_1, 6928c2ecf20Sopenharmony_ci .volt13_op0_op1 = STV0299_VOLT13_OP1, 6938c2ecf20Sopenharmony_ci .min_delay_ms = 50, 6948c2ecf20Sopenharmony_ci .set_symbol_rate = philips_su1278_tt_set_symbol_rate, 6958c2ecf20Sopenharmony_ci}; 6968c2ecf20Sopenharmony_ci 6978c2ecf20Sopenharmony_ci 6988c2ecf20Sopenharmony_ci 6998c2ecf20Sopenharmony_cistatic int philips_tdm1316l_tuner_init(struct dvb_frontend *fe) 7008c2ecf20Sopenharmony_ci{ 7018c2ecf20Sopenharmony_ci struct budget_ci *budget_ci = (struct budget_ci *) fe->dvb->priv; 7028c2ecf20Sopenharmony_ci static u8 td1316_init[] = { 0x0b, 0xf5, 0x85, 0xab }; 7038c2ecf20Sopenharmony_ci static u8 disable_mc44BC374c[] = { 0x1d, 0x74, 0xa0, 0x68 }; 7048c2ecf20Sopenharmony_ci struct i2c_msg tuner_msg = {.addr = budget_ci->tuner_pll_address,.flags = 0,.buf = td1316_init,.len = 7058c2ecf20Sopenharmony_ci sizeof(td1316_init) }; 7068c2ecf20Sopenharmony_ci 7078c2ecf20Sopenharmony_ci // setup PLL configuration 7088c2ecf20Sopenharmony_ci if (fe->ops.i2c_gate_ctrl) 7098c2ecf20Sopenharmony_ci fe->ops.i2c_gate_ctrl(fe, 1); 7108c2ecf20Sopenharmony_ci if (i2c_transfer(&budget_ci->budget.i2c_adap, &tuner_msg, 1) != 1) 7118c2ecf20Sopenharmony_ci return -EIO; 7128c2ecf20Sopenharmony_ci msleep(1); 7138c2ecf20Sopenharmony_ci 7148c2ecf20Sopenharmony_ci // disable the mc44BC374c (do not check for errors) 7158c2ecf20Sopenharmony_ci tuner_msg.addr = 0x65; 7168c2ecf20Sopenharmony_ci tuner_msg.buf = disable_mc44BC374c; 7178c2ecf20Sopenharmony_ci tuner_msg.len = sizeof(disable_mc44BC374c); 7188c2ecf20Sopenharmony_ci if (fe->ops.i2c_gate_ctrl) 7198c2ecf20Sopenharmony_ci fe->ops.i2c_gate_ctrl(fe, 1); 7208c2ecf20Sopenharmony_ci if (i2c_transfer(&budget_ci->budget.i2c_adap, &tuner_msg, 1) != 1) { 7218c2ecf20Sopenharmony_ci if (fe->ops.i2c_gate_ctrl) 7228c2ecf20Sopenharmony_ci fe->ops.i2c_gate_ctrl(fe, 1); 7238c2ecf20Sopenharmony_ci i2c_transfer(&budget_ci->budget.i2c_adap, &tuner_msg, 1); 7248c2ecf20Sopenharmony_ci } 7258c2ecf20Sopenharmony_ci 7268c2ecf20Sopenharmony_ci return 0; 7278c2ecf20Sopenharmony_ci} 7288c2ecf20Sopenharmony_ci 7298c2ecf20Sopenharmony_cistatic int philips_tdm1316l_tuner_set_params(struct dvb_frontend *fe) 7308c2ecf20Sopenharmony_ci{ 7318c2ecf20Sopenharmony_ci struct dtv_frontend_properties *p = &fe->dtv_property_cache; 7328c2ecf20Sopenharmony_ci struct budget_ci *budget_ci = (struct budget_ci *) fe->dvb->priv; 7338c2ecf20Sopenharmony_ci u8 tuner_buf[4]; 7348c2ecf20Sopenharmony_ci struct i2c_msg tuner_msg = {.addr = budget_ci->tuner_pll_address,.flags = 0,.buf = tuner_buf,.len = sizeof(tuner_buf) }; 7358c2ecf20Sopenharmony_ci int tuner_frequency = 0; 7368c2ecf20Sopenharmony_ci u8 band, cp, filter; 7378c2ecf20Sopenharmony_ci 7388c2ecf20Sopenharmony_ci // determine charge pump 7398c2ecf20Sopenharmony_ci tuner_frequency = p->frequency + 36130000; 7408c2ecf20Sopenharmony_ci if (tuner_frequency < 87000000) 7418c2ecf20Sopenharmony_ci return -EINVAL; 7428c2ecf20Sopenharmony_ci else if (tuner_frequency < 130000000) 7438c2ecf20Sopenharmony_ci cp = 3; 7448c2ecf20Sopenharmony_ci else if (tuner_frequency < 160000000) 7458c2ecf20Sopenharmony_ci cp = 5; 7468c2ecf20Sopenharmony_ci else if (tuner_frequency < 200000000) 7478c2ecf20Sopenharmony_ci cp = 6; 7488c2ecf20Sopenharmony_ci else if (tuner_frequency < 290000000) 7498c2ecf20Sopenharmony_ci cp = 3; 7508c2ecf20Sopenharmony_ci else if (tuner_frequency < 420000000) 7518c2ecf20Sopenharmony_ci cp = 5; 7528c2ecf20Sopenharmony_ci else if (tuner_frequency < 480000000) 7538c2ecf20Sopenharmony_ci cp = 6; 7548c2ecf20Sopenharmony_ci else if (tuner_frequency < 620000000) 7558c2ecf20Sopenharmony_ci cp = 3; 7568c2ecf20Sopenharmony_ci else if (tuner_frequency < 830000000) 7578c2ecf20Sopenharmony_ci cp = 5; 7588c2ecf20Sopenharmony_ci else if (tuner_frequency < 895000000) 7598c2ecf20Sopenharmony_ci cp = 7; 7608c2ecf20Sopenharmony_ci else 7618c2ecf20Sopenharmony_ci return -EINVAL; 7628c2ecf20Sopenharmony_ci 7638c2ecf20Sopenharmony_ci // determine band 7648c2ecf20Sopenharmony_ci if (p->frequency < 49000000) 7658c2ecf20Sopenharmony_ci return -EINVAL; 7668c2ecf20Sopenharmony_ci else if (p->frequency < 159000000) 7678c2ecf20Sopenharmony_ci band = 1; 7688c2ecf20Sopenharmony_ci else if (p->frequency < 444000000) 7698c2ecf20Sopenharmony_ci band = 2; 7708c2ecf20Sopenharmony_ci else if (p->frequency < 861000000) 7718c2ecf20Sopenharmony_ci band = 4; 7728c2ecf20Sopenharmony_ci else 7738c2ecf20Sopenharmony_ci return -EINVAL; 7748c2ecf20Sopenharmony_ci 7758c2ecf20Sopenharmony_ci // setup PLL filter and TDA9889 7768c2ecf20Sopenharmony_ci switch (p->bandwidth_hz) { 7778c2ecf20Sopenharmony_ci case 6000000: 7788c2ecf20Sopenharmony_ci tda1004x_writereg(fe, 0x0C, 0x14); 7798c2ecf20Sopenharmony_ci filter = 0; 7808c2ecf20Sopenharmony_ci break; 7818c2ecf20Sopenharmony_ci 7828c2ecf20Sopenharmony_ci case 7000000: 7838c2ecf20Sopenharmony_ci tda1004x_writereg(fe, 0x0C, 0x80); 7848c2ecf20Sopenharmony_ci filter = 0; 7858c2ecf20Sopenharmony_ci break; 7868c2ecf20Sopenharmony_ci 7878c2ecf20Sopenharmony_ci case 8000000: 7888c2ecf20Sopenharmony_ci tda1004x_writereg(fe, 0x0C, 0x14); 7898c2ecf20Sopenharmony_ci filter = 1; 7908c2ecf20Sopenharmony_ci break; 7918c2ecf20Sopenharmony_ci 7928c2ecf20Sopenharmony_ci default: 7938c2ecf20Sopenharmony_ci return -EINVAL; 7948c2ecf20Sopenharmony_ci } 7958c2ecf20Sopenharmony_ci 7968c2ecf20Sopenharmony_ci // calculate divisor 7978c2ecf20Sopenharmony_ci // ((36130000+((1000000/6)/2)) + Finput)/(1000000/6) 7988c2ecf20Sopenharmony_ci tuner_frequency = (((p->frequency / 1000) * 6) + 217280) / 1000; 7998c2ecf20Sopenharmony_ci 8008c2ecf20Sopenharmony_ci // setup tuner buffer 8018c2ecf20Sopenharmony_ci tuner_buf[0] = tuner_frequency >> 8; 8028c2ecf20Sopenharmony_ci tuner_buf[1] = tuner_frequency & 0xff; 8038c2ecf20Sopenharmony_ci tuner_buf[2] = 0xca; 8048c2ecf20Sopenharmony_ci tuner_buf[3] = (cp << 5) | (filter << 3) | band; 8058c2ecf20Sopenharmony_ci 8068c2ecf20Sopenharmony_ci if (fe->ops.i2c_gate_ctrl) 8078c2ecf20Sopenharmony_ci fe->ops.i2c_gate_ctrl(fe, 1); 8088c2ecf20Sopenharmony_ci if (i2c_transfer(&budget_ci->budget.i2c_adap, &tuner_msg, 1) != 1) 8098c2ecf20Sopenharmony_ci return -EIO; 8108c2ecf20Sopenharmony_ci 8118c2ecf20Sopenharmony_ci msleep(1); 8128c2ecf20Sopenharmony_ci return 0; 8138c2ecf20Sopenharmony_ci} 8148c2ecf20Sopenharmony_ci 8158c2ecf20Sopenharmony_cistatic int philips_tdm1316l_request_firmware(struct dvb_frontend *fe, 8168c2ecf20Sopenharmony_ci const struct firmware **fw, char *name) 8178c2ecf20Sopenharmony_ci{ 8188c2ecf20Sopenharmony_ci struct budget_ci *budget_ci = (struct budget_ci *) fe->dvb->priv; 8198c2ecf20Sopenharmony_ci 8208c2ecf20Sopenharmony_ci return request_firmware(fw, name, &budget_ci->budget.dev->pci->dev); 8218c2ecf20Sopenharmony_ci} 8228c2ecf20Sopenharmony_ci 8238c2ecf20Sopenharmony_cistatic struct tda1004x_config philips_tdm1316l_config = { 8248c2ecf20Sopenharmony_ci 8258c2ecf20Sopenharmony_ci .demod_address = 0x8, 8268c2ecf20Sopenharmony_ci .invert = 0, 8278c2ecf20Sopenharmony_ci .invert_oclk = 0, 8288c2ecf20Sopenharmony_ci .xtal_freq = TDA10046_XTAL_4M, 8298c2ecf20Sopenharmony_ci .agc_config = TDA10046_AGC_DEFAULT, 8308c2ecf20Sopenharmony_ci .if_freq = TDA10046_FREQ_3617, 8318c2ecf20Sopenharmony_ci .request_firmware = philips_tdm1316l_request_firmware, 8328c2ecf20Sopenharmony_ci}; 8338c2ecf20Sopenharmony_ci 8348c2ecf20Sopenharmony_cistatic struct tda1004x_config philips_tdm1316l_config_invert = { 8358c2ecf20Sopenharmony_ci 8368c2ecf20Sopenharmony_ci .demod_address = 0x8, 8378c2ecf20Sopenharmony_ci .invert = 1, 8388c2ecf20Sopenharmony_ci .invert_oclk = 0, 8398c2ecf20Sopenharmony_ci .xtal_freq = TDA10046_XTAL_4M, 8408c2ecf20Sopenharmony_ci .agc_config = TDA10046_AGC_DEFAULT, 8418c2ecf20Sopenharmony_ci .if_freq = TDA10046_FREQ_3617, 8428c2ecf20Sopenharmony_ci .request_firmware = philips_tdm1316l_request_firmware, 8438c2ecf20Sopenharmony_ci}; 8448c2ecf20Sopenharmony_ci 8458c2ecf20Sopenharmony_cistatic int dvbc_philips_tdm1316l_tuner_set_params(struct dvb_frontend *fe) 8468c2ecf20Sopenharmony_ci{ 8478c2ecf20Sopenharmony_ci struct dtv_frontend_properties *p = &fe->dtv_property_cache; 8488c2ecf20Sopenharmony_ci struct budget_ci *budget_ci = (struct budget_ci *) fe->dvb->priv; 8498c2ecf20Sopenharmony_ci u8 tuner_buf[5]; 8508c2ecf20Sopenharmony_ci struct i2c_msg tuner_msg = {.addr = budget_ci->tuner_pll_address, 8518c2ecf20Sopenharmony_ci .flags = 0, 8528c2ecf20Sopenharmony_ci .buf = tuner_buf, 8538c2ecf20Sopenharmony_ci .len = sizeof(tuner_buf) }; 8548c2ecf20Sopenharmony_ci int tuner_frequency = 0; 8558c2ecf20Sopenharmony_ci u8 band, cp, filter; 8568c2ecf20Sopenharmony_ci 8578c2ecf20Sopenharmony_ci // determine charge pump 8588c2ecf20Sopenharmony_ci tuner_frequency = p->frequency + 36125000; 8598c2ecf20Sopenharmony_ci if (tuner_frequency < 87000000) 8608c2ecf20Sopenharmony_ci return -EINVAL; 8618c2ecf20Sopenharmony_ci else if (tuner_frequency < 130000000) { 8628c2ecf20Sopenharmony_ci cp = 3; 8638c2ecf20Sopenharmony_ci band = 1; 8648c2ecf20Sopenharmony_ci } else if (tuner_frequency < 160000000) { 8658c2ecf20Sopenharmony_ci cp = 5; 8668c2ecf20Sopenharmony_ci band = 1; 8678c2ecf20Sopenharmony_ci } else if (tuner_frequency < 200000000) { 8688c2ecf20Sopenharmony_ci cp = 6; 8698c2ecf20Sopenharmony_ci band = 1; 8708c2ecf20Sopenharmony_ci } else if (tuner_frequency < 290000000) { 8718c2ecf20Sopenharmony_ci cp = 3; 8728c2ecf20Sopenharmony_ci band = 2; 8738c2ecf20Sopenharmony_ci } else if (tuner_frequency < 420000000) { 8748c2ecf20Sopenharmony_ci cp = 5; 8758c2ecf20Sopenharmony_ci band = 2; 8768c2ecf20Sopenharmony_ci } else if (tuner_frequency < 480000000) { 8778c2ecf20Sopenharmony_ci cp = 6; 8788c2ecf20Sopenharmony_ci band = 2; 8798c2ecf20Sopenharmony_ci } else if (tuner_frequency < 620000000) { 8808c2ecf20Sopenharmony_ci cp = 3; 8818c2ecf20Sopenharmony_ci band = 4; 8828c2ecf20Sopenharmony_ci } else if (tuner_frequency < 830000000) { 8838c2ecf20Sopenharmony_ci cp = 5; 8848c2ecf20Sopenharmony_ci band = 4; 8858c2ecf20Sopenharmony_ci } else if (tuner_frequency < 895000000) { 8868c2ecf20Sopenharmony_ci cp = 7; 8878c2ecf20Sopenharmony_ci band = 4; 8888c2ecf20Sopenharmony_ci } else 8898c2ecf20Sopenharmony_ci return -EINVAL; 8908c2ecf20Sopenharmony_ci 8918c2ecf20Sopenharmony_ci // assume PLL filter should always be 8MHz for the moment. 8928c2ecf20Sopenharmony_ci filter = 1; 8938c2ecf20Sopenharmony_ci 8948c2ecf20Sopenharmony_ci // calculate divisor 8958c2ecf20Sopenharmony_ci tuner_frequency = (p->frequency + 36125000 + (62500/2)) / 62500; 8968c2ecf20Sopenharmony_ci 8978c2ecf20Sopenharmony_ci // setup tuner buffer 8988c2ecf20Sopenharmony_ci tuner_buf[0] = tuner_frequency >> 8; 8998c2ecf20Sopenharmony_ci tuner_buf[1] = tuner_frequency & 0xff; 9008c2ecf20Sopenharmony_ci tuner_buf[2] = 0xc8; 9018c2ecf20Sopenharmony_ci tuner_buf[3] = (cp << 5) | (filter << 3) | band; 9028c2ecf20Sopenharmony_ci tuner_buf[4] = 0x80; 9038c2ecf20Sopenharmony_ci 9048c2ecf20Sopenharmony_ci if (fe->ops.i2c_gate_ctrl) 9058c2ecf20Sopenharmony_ci fe->ops.i2c_gate_ctrl(fe, 1); 9068c2ecf20Sopenharmony_ci if (i2c_transfer(&budget_ci->budget.i2c_adap, &tuner_msg, 1) != 1) 9078c2ecf20Sopenharmony_ci return -EIO; 9088c2ecf20Sopenharmony_ci 9098c2ecf20Sopenharmony_ci msleep(50); 9108c2ecf20Sopenharmony_ci 9118c2ecf20Sopenharmony_ci if (fe->ops.i2c_gate_ctrl) 9128c2ecf20Sopenharmony_ci fe->ops.i2c_gate_ctrl(fe, 1); 9138c2ecf20Sopenharmony_ci if (i2c_transfer(&budget_ci->budget.i2c_adap, &tuner_msg, 1) != 1) 9148c2ecf20Sopenharmony_ci return -EIO; 9158c2ecf20Sopenharmony_ci 9168c2ecf20Sopenharmony_ci msleep(1); 9178c2ecf20Sopenharmony_ci 9188c2ecf20Sopenharmony_ci return 0; 9198c2ecf20Sopenharmony_ci} 9208c2ecf20Sopenharmony_ci 9218c2ecf20Sopenharmony_cistatic u8 dvbc_philips_tdm1316l_inittab[] = { 9228c2ecf20Sopenharmony_ci 0x80, 0x01, 9238c2ecf20Sopenharmony_ci 0x80, 0x00, 9248c2ecf20Sopenharmony_ci 0x81, 0x01, 9258c2ecf20Sopenharmony_ci 0x81, 0x00, 9268c2ecf20Sopenharmony_ci 0x00, 0x09, 9278c2ecf20Sopenharmony_ci 0x01, 0x69, 9288c2ecf20Sopenharmony_ci 0x03, 0x00, 9298c2ecf20Sopenharmony_ci 0x04, 0x00, 9308c2ecf20Sopenharmony_ci 0x07, 0x00, 9318c2ecf20Sopenharmony_ci 0x08, 0x00, 9328c2ecf20Sopenharmony_ci 0x20, 0x00, 9338c2ecf20Sopenharmony_ci 0x21, 0x40, 9348c2ecf20Sopenharmony_ci 0x22, 0x00, 9358c2ecf20Sopenharmony_ci 0x23, 0x00, 9368c2ecf20Sopenharmony_ci 0x24, 0x40, 9378c2ecf20Sopenharmony_ci 0x25, 0x88, 9388c2ecf20Sopenharmony_ci 0x30, 0xff, 9398c2ecf20Sopenharmony_ci 0x31, 0x00, 9408c2ecf20Sopenharmony_ci 0x32, 0xff, 9418c2ecf20Sopenharmony_ci 0x33, 0x00, 9428c2ecf20Sopenharmony_ci 0x34, 0x50, 9438c2ecf20Sopenharmony_ci 0x35, 0x7f, 9448c2ecf20Sopenharmony_ci 0x36, 0x00, 9458c2ecf20Sopenharmony_ci 0x37, 0x20, 9468c2ecf20Sopenharmony_ci 0x38, 0x00, 9478c2ecf20Sopenharmony_ci 0x40, 0x1c, 9488c2ecf20Sopenharmony_ci 0x41, 0xff, 9498c2ecf20Sopenharmony_ci 0x42, 0x29, 9508c2ecf20Sopenharmony_ci 0x43, 0x20, 9518c2ecf20Sopenharmony_ci 0x44, 0xff, 9528c2ecf20Sopenharmony_ci 0x45, 0x00, 9538c2ecf20Sopenharmony_ci 0x46, 0x00, 9548c2ecf20Sopenharmony_ci 0x49, 0x04, 9558c2ecf20Sopenharmony_ci 0x4a, 0x00, 9568c2ecf20Sopenharmony_ci 0x4b, 0x7b, 9578c2ecf20Sopenharmony_ci 0x52, 0x30, 9588c2ecf20Sopenharmony_ci 0x55, 0xae, 9598c2ecf20Sopenharmony_ci 0x56, 0x47, 9608c2ecf20Sopenharmony_ci 0x57, 0xe1, 9618c2ecf20Sopenharmony_ci 0x58, 0x3a, 9628c2ecf20Sopenharmony_ci 0x5a, 0x1e, 9638c2ecf20Sopenharmony_ci 0x5b, 0x34, 9648c2ecf20Sopenharmony_ci 0x60, 0x00, 9658c2ecf20Sopenharmony_ci 0x63, 0x00, 9668c2ecf20Sopenharmony_ci 0x64, 0x00, 9678c2ecf20Sopenharmony_ci 0x65, 0x00, 9688c2ecf20Sopenharmony_ci 0x66, 0x00, 9698c2ecf20Sopenharmony_ci 0x67, 0x00, 9708c2ecf20Sopenharmony_ci 0x68, 0x00, 9718c2ecf20Sopenharmony_ci 0x69, 0x00, 9728c2ecf20Sopenharmony_ci 0x6a, 0x02, 9738c2ecf20Sopenharmony_ci 0x6b, 0x00, 9748c2ecf20Sopenharmony_ci 0x70, 0xff, 9758c2ecf20Sopenharmony_ci 0x71, 0x00, 9768c2ecf20Sopenharmony_ci 0x72, 0x00, 9778c2ecf20Sopenharmony_ci 0x73, 0x00, 9788c2ecf20Sopenharmony_ci 0x74, 0x0c, 9798c2ecf20Sopenharmony_ci 0x80, 0x00, 9808c2ecf20Sopenharmony_ci 0x81, 0x00, 9818c2ecf20Sopenharmony_ci 0x82, 0x00, 9828c2ecf20Sopenharmony_ci 0x83, 0x00, 9838c2ecf20Sopenharmony_ci 0x84, 0x04, 9848c2ecf20Sopenharmony_ci 0x85, 0x80, 9858c2ecf20Sopenharmony_ci 0x86, 0x24, 9868c2ecf20Sopenharmony_ci 0x87, 0x78, 9878c2ecf20Sopenharmony_ci 0x88, 0x10, 9888c2ecf20Sopenharmony_ci 0x89, 0x00, 9898c2ecf20Sopenharmony_ci 0x90, 0x01, 9908c2ecf20Sopenharmony_ci 0x91, 0x01, 9918c2ecf20Sopenharmony_ci 0xa0, 0x04, 9928c2ecf20Sopenharmony_ci 0xa1, 0x00, 9938c2ecf20Sopenharmony_ci 0xa2, 0x00, 9948c2ecf20Sopenharmony_ci 0xb0, 0x91, 9958c2ecf20Sopenharmony_ci 0xb1, 0x0b, 9968c2ecf20Sopenharmony_ci 0xc0, 0x53, 9978c2ecf20Sopenharmony_ci 0xc1, 0x70, 9988c2ecf20Sopenharmony_ci 0xc2, 0x12, 9998c2ecf20Sopenharmony_ci 0xd0, 0x00, 10008c2ecf20Sopenharmony_ci 0xd1, 0x00, 10018c2ecf20Sopenharmony_ci 0xd2, 0x00, 10028c2ecf20Sopenharmony_ci 0xd3, 0x00, 10038c2ecf20Sopenharmony_ci 0xd4, 0x00, 10048c2ecf20Sopenharmony_ci 0xd5, 0x00, 10058c2ecf20Sopenharmony_ci 0xde, 0x00, 10068c2ecf20Sopenharmony_ci 0xdf, 0x00, 10078c2ecf20Sopenharmony_ci 0x61, 0x38, 10088c2ecf20Sopenharmony_ci 0x62, 0x0a, 10098c2ecf20Sopenharmony_ci 0x53, 0x13, 10108c2ecf20Sopenharmony_ci 0x59, 0x08, 10118c2ecf20Sopenharmony_ci 0xff, 0xff, 10128c2ecf20Sopenharmony_ci}; 10138c2ecf20Sopenharmony_ci 10148c2ecf20Sopenharmony_cistatic struct stv0297_config dvbc_philips_tdm1316l_config = { 10158c2ecf20Sopenharmony_ci .demod_address = 0x1c, 10168c2ecf20Sopenharmony_ci .inittab = dvbc_philips_tdm1316l_inittab, 10178c2ecf20Sopenharmony_ci .invert = 0, 10188c2ecf20Sopenharmony_ci .stop_during_read = 1, 10198c2ecf20Sopenharmony_ci}; 10208c2ecf20Sopenharmony_ci 10218c2ecf20Sopenharmony_cistatic struct tda10023_config tda10023_config = { 10228c2ecf20Sopenharmony_ci .demod_address = 0xc, 10238c2ecf20Sopenharmony_ci .invert = 0, 10248c2ecf20Sopenharmony_ci .xtal = 16000000, 10258c2ecf20Sopenharmony_ci .pll_m = 11, 10268c2ecf20Sopenharmony_ci .pll_p = 3, 10278c2ecf20Sopenharmony_ci .pll_n = 1, 10288c2ecf20Sopenharmony_ci .deltaf = 0xa511, 10298c2ecf20Sopenharmony_ci}; 10308c2ecf20Sopenharmony_ci 10318c2ecf20Sopenharmony_cistatic struct tda827x_config tda827x_config = { 10328c2ecf20Sopenharmony_ci .config = 0, 10338c2ecf20Sopenharmony_ci}; 10348c2ecf20Sopenharmony_ci 10358c2ecf20Sopenharmony_ci/* TT S2-3200 DVB-S (STB0899) Inittab */ 10368c2ecf20Sopenharmony_cistatic const struct stb0899_s1_reg tt3200_stb0899_s1_init_1[] = { 10378c2ecf20Sopenharmony_ci 10388c2ecf20Sopenharmony_ci { STB0899_DEV_ID , 0x81 }, 10398c2ecf20Sopenharmony_ci { STB0899_DISCNTRL1 , 0x32 }, 10408c2ecf20Sopenharmony_ci { STB0899_DISCNTRL2 , 0x80 }, 10418c2ecf20Sopenharmony_ci { STB0899_DISRX_ST0 , 0x04 }, 10428c2ecf20Sopenharmony_ci { STB0899_DISRX_ST1 , 0x00 }, 10438c2ecf20Sopenharmony_ci { STB0899_DISPARITY , 0x00 }, 10448c2ecf20Sopenharmony_ci { STB0899_DISSTATUS , 0x20 }, 10458c2ecf20Sopenharmony_ci { STB0899_DISF22 , 0x8c }, 10468c2ecf20Sopenharmony_ci { STB0899_DISF22RX , 0x9a }, 10478c2ecf20Sopenharmony_ci { STB0899_SYSREG , 0x0b }, 10488c2ecf20Sopenharmony_ci { STB0899_ACRPRESC , 0x11 }, 10498c2ecf20Sopenharmony_ci { STB0899_ACRDIV1 , 0x0a }, 10508c2ecf20Sopenharmony_ci { STB0899_ACRDIV2 , 0x05 }, 10518c2ecf20Sopenharmony_ci { STB0899_DACR1 , 0x00 }, 10528c2ecf20Sopenharmony_ci { STB0899_DACR2 , 0x00 }, 10538c2ecf20Sopenharmony_ci { STB0899_OUTCFG , 0x00 }, 10548c2ecf20Sopenharmony_ci { STB0899_MODECFG , 0x00 }, 10558c2ecf20Sopenharmony_ci { STB0899_IRQSTATUS_3 , 0x30 }, 10568c2ecf20Sopenharmony_ci { STB0899_IRQSTATUS_2 , 0x00 }, 10578c2ecf20Sopenharmony_ci { STB0899_IRQSTATUS_1 , 0x00 }, 10588c2ecf20Sopenharmony_ci { STB0899_IRQSTATUS_0 , 0x00 }, 10598c2ecf20Sopenharmony_ci { STB0899_IRQMSK_3 , 0xf3 }, 10608c2ecf20Sopenharmony_ci { STB0899_IRQMSK_2 , 0xfc }, 10618c2ecf20Sopenharmony_ci { STB0899_IRQMSK_1 , 0xff }, 10628c2ecf20Sopenharmony_ci { STB0899_IRQMSK_0 , 0xff }, 10638c2ecf20Sopenharmony_ci { STB0899_IRQCFG , 0x00 }, 10648c2ecf20Sopenharmony_ci { STB0899_I2CCFG , 0x88 }, 10658c2ecf20Sopenharmony_ci { STB0899_I2CRPT , 0x48 }, /* 12k Pullup, Repeater=16, Stop=disabled */ 10668c2ecf20Sopenharmony_ci { STB0899_IOPVALUE5 , 0x00 }, 10678c2ecf20Sopenharmony_ci { STB0899_IOPVALUE4 , 0x20 }, 10688c2ecf20Sopenharmony_ci { STB0899_IOPVALUE3 , 0xc9 }, 10698c2ecf20Sopenharmony_ci { STB0899_IOPVALUE2 , 0x90 }, 10708c2ecf20Sopenharmony_ci { STB0899_IOPVALUE1 , 0x40 }, 10718c2ecf20Sopenharmony_ci { STB0899_IOPVALUE0 , 0x00 }, 10728c2ecf20Sopenharmony_ci { STB0899_GPIO00CFG , 0x82 }, 10738c2ecf20Sopenharmony_ci { STB0899_GPIO01CFG , 0x82 }, 10748c2ecf20Sopenharmony_ci { STB0899_GPIO02CFG , 0x82 }, 10758c2ecf20Sopenharmony_ci { STB0899_GPIO03CFG , 0x82 }, 10768c2ecf20Sopenharmony_ci { STB0899_GPIO04CFG , 0x82 }, 10778c2ecf20Sopenharmony_ci { STB0899_GPIO05CFG , 0x82 }, 10788c2ecf20Sopenharmony_ci { STB0899_GPIO06CFG , 0x82 }, 10798c2ecf20Sopenharmony_ci { STB0899_GPIO07CFG , 0x82 }, 10808c2ecf20Sopenharmony_ci { STB0899_GPIO08CFG , 0x82 }, 10818c2ecf20Sopenharmony_ci { STB0899_GPIO09CFG , 0x82 }, 10828c2ecf20Sopenharmony_ci { STB0899_GPIO10CFG , 0x82 }, 10838c2ecf20Sopenharmony_ci { STB0899_GPIO11CFG , 0x82 }, 10848c2ecf20Sopenharmony_ci { STB0899_GPIO12CFG , 0x82 }, 10858c2ecf20Sopenharmony_ci { STB0899_GPIO13CFG , 0x82 }, 10868c2ecf20Sopenharmony_ci { STB0899_GPIO14CFG , 0x82 }, 10878c2ecf20Sopenharmony_ci { STB0899_GPIO15CFG , 0x82 }, 10888c2ecf20Sopenharmony_ci { STB0899_GPIO16CFG , 0x82 }, 10898c2ecf20Sopenharmony_ci { STB0899_GPIO17CFG , 0x82 }, 10908c2ecf20Sopenharmony_ci { STB0899_GPIO18CFG , 0x82 }, 10918c2ecf20Sopenharmony_ci { STB0899_GPIO19CFG , 0x82 }, 10928c2ecf20Sopenharmony_ci { STB0899_GPIO20CFG , 0x82 }, 10938c2ecf20Sopenharmony_ci { STB0899_SDATCFG , 0xb8 }, 10948c2ecf20Sopenharmony_ci { STB0899_SCLTCFG , 0xba }, 10958c2ecf20Sopenharmony_ci { STB0899_AGCRFCFG , 0x1c }, /* 0x11 */ 10968c2ecf20Sopenharmony_ci { STB0899_GPIO22 , 0x82 }, /* AGCBB2CFG */ 10978c2ecf20Sopenharmony_ci { STB0899_GPIO21 , 0x91 }, /* AGCBB1CFG */ 10988c2ecf20Sopenharmony_ci { STB0899_DIRCLKCFG , 0x82 }, 10998c2ecf20Sopenharmony_ci { STB0899_CLKOUT27CFG , 0x7e }, 11008c2ecf20Sopenharmony_ci { STB0899_STDBYCFG , 0x82 }, 11018c2ecf20Sopenharmony_ci { STB0899_CS0CFG , 0x82 }, 11028c2ecf20Sopenharmony_ci { STB0899_CS1CFG , 0x82 }, 11038c2ecf20Sopenharmony_ci { STB0899_DISEQCOCFG , 0x20 }, 11048c2ecf20Sopenharmony_ci { STB0899_GPIO32CFG , 0x82 }, 11058c2ecf20Sopenharmony_ci { STB0899_GPIO33CFG , 0x82 }, 11068c2ecf20Sopenharmony_ci { STB0899_GPIO34CFG , 0x82 }, 11078c2ecf20Sopenharmony_ci { STB0899_GPIO35CFG , 0x82 }, 11088c2ecf20Sopenharmony_ci { STB0899_GPIO36CFG , 0x82 }, 11098c2ecf20Sopenharmony_ci { STB0899_GPIO37CFG , 0x82 }, 11108c2ecf20Sopenharmony_ci { STB0899_GPIO38CFG , 0x82 }, 11118c2ecf20Sopenharmony_ci { STB0899_GPIO39CFG , 0x82 }, 11128c2ecf20Sopenharmony_ci { STB0899_NCOARSE , 0x15 }, /* 0x15 = 27 Mhz Clock, F/3 = 198MHz, F/6 = 99MHz */ 11138c2ecf20Sopenharmony_ci { STB0899_SYNTCTRL , 0x02 }, /* 0x00 = CLK from CLKI, 0x02 = CLK from XTALI */ 11148c2ecf20Sopenharmony_ci { STB0899_FILTCTRL , 0x00 }, 11158c2ecf20Sopenharmony_ci { STB0899_SYSCTRL , 0x00 }, 11168c2ecf20Sopenharmony_ci { STB0899_STOPCLK1 , 0x20 }, 11178c2ecf20Sopenharmony_ci { STB0899_STOPCLK2 , 0x00 }, 11188c2ecf20Sopenharmony_ci { STB0899_INTBUFSTATUS , 0x00 }, 11198c2ecf20Sopenharmony_ci { STB0899_INTBUFCTRL , 0x0a }, 11208c2ecf20Sopenharmony_ci { 0xffff , 0xff }, 11218c2ecf20Sopenharmony_ci}; 11228c2ecf20Sopenharmony_ci 11238c2ecf20Sopenharmony_cistatic const struct stb0899_s1_reg tt3200_stb0899_s1_init_3[] = { 11248c2ecf20Sopenharmony_ci { STB0899_DEMOD , 0x00 }, 11258c2ecf20Sopenharmony_ci { STB0899_RCOMPC , 0xc9 }, 11268c2ecf20Sopenharmony_ci { STB0899_AGC1CN , 0x41 }, 11278c2ecf20Sopenharmony_ci { STB0899_AGC1REF , 0x10 }, 11288c2ecf20Sopenharmony_ci { STB0899_RTC , 0x7a }, 11298c2ecf20Sopenharmony_ci { STB0899_TMGCFG , 0x4e }, 11308c2ecf20Sopenharmony_ci { STB0899_AGC2REF , 0x34 }, 11318c2ecf20Sopenharmony_ci { STB0899_TLSR , 0x84 }, 11328c2ecf20Sopenharmony_ci { STB0899_CFD , 0xc7 }, 11338c2ecf20Sopenharmony_ci { STB0899_ACLC , 0x87 }, 11348c2ecf20Sopenharmony_ci { STB0899_BCLC , 0x94 }, 11358c2ecf20Sopenharmony_ci { STB0899_EQON , 0x41 }, 11368c2ecf20Sopenharmony_ci { STB0899_LDT , 0xdd }, 11378c2ecf20Sopenharmony_ci { STB0899_LDT2 , 0xc9 }, 11388c2ecf20Sopenharmony_ci { STB0899_EQUALREF , 0xb4 }, 11398c2ecf20Sopenharmony_ci { STB0899_TMGRAMP , 0x10 }, 11408c2ecf20Sopenharmony_ci { STB0899_TMGTHD , 0x30 }, 11418c2ecf20Sopenharmony_ci { STB0899_IDCCOMP , 0xfb }, 11428c2ecf20Sopenharmony_ci { STB0899_QDCCOMP , 0x03 }, 11438c2ecf20Sopenharmony_ci { STB0899_POWERI , 0x3b }, 11448c2ecf20Sopenharmony_ci { STB0899_POWERQ , 0x3d }, 11458c2ecf20Sopenharmony_ci { STB0899_RCOMP , 0x81 }, 11468c2ecf20Sopenharmony_ci { STB0899_AGCIQIN , 0x80 }, 11478c2ecf20Sopenharmony_ci { STB0899_AGC2I1 , 0x04 }, 11488c2ecf20Sopenharmony_ci { STB0899_AGC2I2 , 0xf5 }, 11498c2ecf20Sopenharmony_ci { STB0899_TLIR , 0x25 }, 11508c2ecf20Sopenharmony_ci { STB0899_RTF , 0x80 }, 11518c2ecf20Sopenharmony_ci { STB0899_DSTATUS , 0x00 }, 11528c2ecf20Sopenharmony_ci { STB0899_LDI , 0xca }, 11538c2ecf20Sopenharmony_ci { STB0899_CFRM , 0xf1 }, 11548c2ecf20Sopenharmony_ci { STB0899_CFRL , 0xf3 }, 11558c2ecf20Sopenharmony_ci { STB0899_NIRM , 0x2a }, 11568c2ecf20Sopenharmony_ci { STB0899_NIRL , 0x05 }, 11578c2ecf20Sopenharmony_ci { STB0899_ISYMB , 0x17 }, 11588c2ecf20Sopenharmony_ci { STB0899_QSYMB , 0xfa }, 11598c2ecf20Sopenharmony_ci { STB0899_SFRH , 0x2f }, 11608c2ecf20Sopenharmony_ci { STB0899_SFRM , 0x68 }, 11618c2ecf20Sopenharmony_ci { STB0899_SFRL , 0x40 }, 11628c2ecf20Sopenharmony_ci { STB0899_SFRUPH , 0x2f }, 11638c2ecf20Sopenharmony_ci { STB0899_SFRUPM , 0x68 }, 11648c2ecf20Sopenharmony_ci { STB0899_SFRUPL , 0x40 }, 11658c2ecf20Sopenharmony_ci { STB0899_EQUAI1 , 0xfd }, 11668c2ecf20Sopenharmony_ci { STB0899_EQUAQ1 , 0x04 }, 11678c2ecf20Sopenharmony_ci { STB0899_EQUAI2 , 0x0f }, 11688c2ecf20Sopenharmony_ci { STB0899_EQUAQ2 , 0xff }, 11698c2ecf20Sopenharmony_ci { STB0899_EQUAI3 , 0xdf }, 11708c2ecf20Sopenharmony_ci { STB0899_EQUAQ3 , 0xfa }, 11718c2ecf20Sopenharmony_ci { STB0899_EQUAI4 , 0x37 }, 11728c2ecf20Sopenharmony_ci { STB0899_EQUAQ4 , 0x0d }, 11738c2ecf20Sopenharmony_ci { STB0899_EQUAI5 , 0xbd }, 11748c2ecf20Sopenharmony_ci { STB0899_EQUAQ5 , 0xf7 }, 11758c2ecf20Sopenharmony_ci { STB0899_DSTATUS2 , 0x00 }, 11768c2ecf20Sopenharmony_ci { STB0899_VSTATUS , 0x00 }, 11778c2ecf20Sopenharmony_ci { STB0899_VERROR , 0xff }, 11788c2ecf20Sopenharmony_ci { STB0899_IQSWAP , 0x2a }, 11798c2ecf20Sopenharmony_ci { STB0899_ECNT1M , 0x00 }, 11808c2ecf20Sopenharmony_ci { STB0899_ECNT1L , 0x00 }, 11818c2ecf20Sopenharmony_ci { STB0899_ECNT2M , 0x00 }, 11828c2ecf20Sopenharmony_ci { STB0899_ECNT2L , 0x00 }, 11838c2ecf20Sopenharmony_ci { STB0899_ECNT3M , 0x00 }, 11848c2ecf20Sopenharmony_ci { STB0899_ECNT3L , 0x00 }, 11858c2ecf20Sopenharmony_ci { STB0899_FECAUTO1 , 0x06 }, 11868c2ecf20Sopenharmony_ci { STB0899_FECM , 0x01 }, 11878c2ecf20Sopenharmony_ci { STB0899_VTH12 , 0xf0 }, 11888c2ecf20Sopenharmony_ci { STB0899_VTH23 , 0xa0 }, 11898c2ecf20Sopenharmony_ci { STB0899_VTH34 , 0x78 }, 11908c2ecf20Sopenharmony_ci { STB0899_VTH56 , 0x4e }, 11918c2ecf20Sopenharmony_ci { STB0899_VTH67 , 0x48 }, 11928c2ecf20Sopenharmony_ci { STB0899_VTH78 , 0x38 }, 11938c2ecf20Sopenharmony_ci { STB0899_PRVIT , 0xff }, 11948c2ecf20Sopenharmony_ci { STB0899_VITSYNC , 0x19 }, 11958c2ecf20Sopenharmony_ci { STB0899_RSULC , 0xb1 }, /* DVB = 0xb1, DSS = 0xa1 */ 11968c2ecf20Sopenharmony_ci { STB0899_TSULC , 0x42 }, 11978c2ecf20Sopenharmony_ci { STB0899_RSLLC , 0x40 }, 11988c2ecf20Sopenharmony_ci { STB0899_TSLPL , 0x12 }, 11998c2ecf20Sopenharmony_ci { STB0899_TSCFGH , 0x0c }, 12008c2ecf20Sopenharmony_ci { STB0899_TSCFGM , 0x00 }, 12018c2ecf20Sopenharmony_ci { STB0899_TSCFGL , 0x0c }, 12028c2ecf20Sopenharmony_ci { STB0899_TSOUT , 0x4d }, /* 0x0d for CAM */ 12038c2ecf20Sopenharmony_ci { STB0899_RSSYNCDEL , 0x00 }, 12048c2ecf20Sopenharmony_ci { STB0899_TSINHDELH , 0x02 }, 12058c2ecf20Sopenharmony_ci { STB0899_TSINHDELM , 0x00 }, 12068c2ecf20Sopenharmony_ci { STB0899_TSINHDELL , 0x00 }, 12078c2ecf20Sopenharmony_ci { STB0899_TSLLSTKM , 0x00 }, 12088c2ecf20Sopenharmony_ci { STB0899_TSLLSTKL , 0x00 }, 12098c2ecf20Sopenharmony_ci { STB0899_TSULSTKM , 0x00 }, 12108c2ecf20Sopenharmony_ci { STB0899_TSULSTKL , 0xab }, 12118c2ecf20Sopenharmony_ci { STB0899_PCKLENUL , 0x00 }, 12128c2ecf20Sopenharmony_ci { STB0899_PCKLENLL , 0xcc }, 12138c2ecf20Sopenharmony_ci { STB0899_RSPCKLEN , 0xcc }, 12148c2ecf20Sopenharmony_ci { STB0899_TSSTATUS , 0x80 }, 12158c2ecf20Sopenharmony_ci { STB0899_ERRCTRL1 , 0xb6 }, 12168c2ecf20Sopenharmony_ci { STB0899_ERRCTRL2 , 0x96 }, 12178c2ecf20Sopenharmony_ci { STB0899_ERRCTRL3 , 0x89 }, 12188c2ecf20Sopenharmony_ci { STB0899_DMONMSK1 , 0x27 }, 12198c2ecf20Sopenharmony_ci { STB0899_DMONMSK0 , 0x03 }, 12208c2ecf20Sopenharmony_ci { STB0899_DEMAPVIT , 0x5c }, 12218c2ecf20Sopenharmony_ci { STB0899_PLPARM , 0x1f }, 12228c2ecf20Sopenharmony_ci { STB0899_PDELCTRL , 0x48 }, 12238c2ecf20Sopenharmony_ci { STB0899_PDELCTRL2 , 0x00 }, 12248c2ecf20Sopenharmony_ci { STB0899_BBHCTRL1 , 0x00 }, 12258c2ecf20Sopenharmony_ci { STB0899_BBHCTRL2 , 0x00 }, 12268c2ecf20Sopenharmony_ci { STB0899_HYSTTHRESH , 0x77 }, 12278c2ecf20Sopenharmony_ci { STB0899_MATCSTM , 0x00 }, 12288c2ecf20Sopenharmony_ci { STB0899_MATCSTL , 0x00 }, 12298c2ecf20Sopenharmony_ci { STB0899_UPLCSTM , 0x00 }, 12308c2ecf20Sopenharmony_ci { STB0899_UPLCSTL , 0x00 }, 12318c2ecf20Sopenharmony_ci { STB0899_DFLCSTM , 0x00 }, 12328c2ecf20Sopenharmony_ci { STB0899_DFLCSTL , 0x00 }, 12338c2ecf20Sopenharmony_ci { STB0899_SYNCCST , 0x00 }, 12348c2ecf20Sopenharmony_ci { STB0899_SYNCDCSTM , 0x00 }, 12358c2ecf20Sopenharmony_ci { STB0899_SYNCDCSTL , 0x00 }, 12368c2ecf20Sopenharmony_ci { STB0899_ISI_ENTRY , 0x00 }, 12378c2ecf20Sopenharmony_ci { STB0899_ISI_BIT_EN , 0x00 }, 12388c2ecf20Sopenharmony_ci { STB0899_MATSTRM , 0x00 }, 12398c2ecf20Sopenharmony_ci { STB0899_MATSTRL , 0x00 }, 12408c2ecf20Sopenharmony_ci { STB0899_UPLSTRM , 0x00 }, 12418c2ecf20Sopenharmony_ci { STB0899_UPLSTRL , 0x00 }, 12428c2ecf20Sopenharmony_ci { STB0899_DFLSTRM , 0x00 }, 12438c2ecf20Sopenharmony_ci { STB0899_DFLSTRL , 0x00 }, 12448c2ecf20Sopenharmony_ci { STB0899_SYNCSTR , 0x00 }, 12458c2ecf20Sopenharmony_ci { STB0899_SYNCDSTRM , 0x00 }, 12468c2ecf20Sopenharmony_ci { STB0899_SYNCDSTRL , 0x00 }, 12478c2ecf20Sopenharmony_ci { STB0899_CFGPDELSTATUS1 , 0x10 }, 12488c2ecf20Sopenharmony_ci { STB0899_CFGPDELSTATUS2 , 0x00 }, 12498c2ecf20Sopenharmony_ci { STB0899_BBFERRORM , 0x00 }, 12508c2ecf20Sopenharmony_ci { STB0899_BBFERRORL , 0x00 }, 12518c2ecf20Sopenharmony_ci { STB0899_UPKTERRORM , 0x00 }, 12528c2ecf20Sopenharmony_ci { STB0899_UPKTERRORL , 0x00 }, 12538c2ecf20Sopenharmony_ci { 0xffff , 0xff }, 12548c2ecf20Sopenharmony_ci}; 12558c2ecf20Sopenharmony_ci 12568c2ecf20Sopenharmony_cistatic struct stb0899_config tt3200_config = { 12578c2ecf20Sopenharmony_ci .init_dev = tt3200_stb0899_s1_init_1, 12588c2ecf20Sopenharmony_ci .init_s2_demod = stb0899_s2_init_2, 12598c2ecf20Sopenharmony_ci .init_s1_demod = tt3200_stb0899_s1_init_3, 12608c2ecf20Sopenharmony_ci .init_s2_fec = stb0899_s2_init_4, 12618c2ecf20Sopenharmony_ci .init_tst = stb0899_s1_init_5, 12628c2ecf20Sopenharmony_ci 12638c2ecf20Sopenharmony_ci .postproc = NULL, 12648c2ecf20Sopenharmony_ci 12658c2ecf20Sopenharmony_ci .demod_address = 0x68, 12668c2ecf20Sopenharmony_ci 12678c2ecf20Sopenharmony_ci .xtal_freq = 27000000, 12688c2ecf20Sopenharmony_ci .inversion = IQ_SWAP_ON, 12698c2ecf20Sopenharmony_ci 12708c2ecf20Sopenharmony_ci .lo_clk = 76500000, 12718c2ecf20Sopenharmony_ci .hi_clk = 99000000, 12728c2ecf20Sopenharmony_ci 12738c2ecf20Sopenharmony_ci .esno_ave = STB0899_DVBS2_ESNO_AVE, 12748c2ecf20Sopenharmony_ci .esno_quant = STB0899_DVBS2_ESNO_QUANT, 12758c2ecf20Sopenharmony_ci .avframes_coarse = STB0899_DVBS2_AVFRAMES_COARSE, 12768c2ecf20Sopenharmony_ci .avframes_fine = STB0899_DVBS2_AVFRAMES_FINE, 12778c2ecf20Sopenharmony_ci .miss_threshold = STB0899_DVBS2_MISS_THRESHOLD, 12788c2ecf20Sopenharmony_ci .uwp_threshold_acq = STB0899_DVBS2_UWP_THRESHOLD_ACQ, 12798c2ecf20Sopenharmony_ci .uwp_threshold_track = STB0899_DVBS2_UWP_THRESHOLD_TRACK, 12808c2ecf20Sopenharmony_ci .uwp_threshold_sof = STB0899_DVBS2_UWP_THRESHOLD_SOF, 12818c2ecf20Sopenharmony_ci .sof_search_timeout = STB0899_DVBS2_SOF_SEARCH_TIMEOUT, 12828c2ecf20Sopenharmony_ci 12838c2ecf20Sopenharmony_ci .btr_nco_bits = STB0899_DVBS2_BTR_NCO_BITS, 12848c2ecf20Sopenharmony_ci .btr_gain_shift_offset = STB0899_DVBS2_BTR_GAIN_SHIFT_OFFSET, 12858c2ecf20Sopenharmony_ci .crl_nco_bits = STB0899_DVBS2_CRL_NCO_BITS, 12868c2ecf20Sopenharmony_ci .ldpc_max_iter = STB0899_DVBS2_LDPC_MAX_ITER, 12878c2ecf20Sopenharmony_ci 12888c2ecf20Sopenharmony_ci .tuner_get_frequency = stb6100_get_frequency, 12898c2ecf20Sopenharmony_ci .tuner_set_frequency = stb6100_set_frequency, 12908c2ecf20Sopenharmony_ci .tuner_set_bandwidth = stb6100_set_bandwidth, 12918c2ecf20Sopenharmony_ci .tuner_get_bandwidth = stb6100_get_bandwidth, 12928c2ecf20Sopenharmony_ci .tuner_set_rfsiggain = NULL 12938c2ecf20Sopenharmony_ci}; 12948c2ecf20Sopenharmony_ci 12958c2ecf20Sopenharmony_cistatic struct stb6100_config tt3200_stb6100_config = { 12968c2ecf20Sopenharmony_ci .tuner_address = 0x60, 12978c2ecf20Sopenharmony_ci .refclock = 27000000, 12988c2ecf20Sopenharmony_ci}; 12998c2ecf20Sopenharmony_ci 13008c2ecf20Sopenharmony_cistatic void frontend_init(struct budget_ci *budget_ci) 13018c2ecf20Sopenharmony_ci{ 13028c2ecf20Sopenharmony_ci switch (budget_ci->budget.dev->pci->subsystem_device) { 13038c2ecf20Sopenharmony_ci case 0x100c: // Hauppauge/TT Nova-CI budget (stv0299/ALPS BSRU6(tsa5059)) 13048c2ecf20Sopenharmony_ci budget_ci->budget.dvb_frontend = 13058c2ecf20Sopenharmony_ci dvb_attach(stv0299_attach, &alps_bsru6_config, &budget_ci->budget.i2c_adap); 13068c2ecf20Sopenharmony_ci if (budget_ci->budget.dvb_frontend) { 13078c2ecf20Sopenharmony_ci budget_ci->budget.dvb_frontend->ops.tuner_ops.set_params = alps_bsru6_tuner_set_params; 13088c2ecf20Sopenharmony_ci budget_ci->budget.dvb_frontend->tuner_priv = &budget_ci->budget.i2c_adap; 13098c2ecf20Sopenharmony_ci break; 13108c2ecf20Sopenharmony_ci } 13118c2ecf20Sopenharmony_ci break; 13128c2ecf20Sopenharmony_ci 13138c2ecf20Sopenharmony_ci case 0x100f: // Hauppauge/TT Nova-CI budget (stv0299b/Philips su1278(tsa5059)) 13148c2ecf20Sopenharmony_ci budget_ci->budget.dvb_frontend = 13158c2ecf20Sopenharmony_ci dvb_attach(stv0299_attach, &philips_su1278_tt_config, &budget_ci->budget.i2c_adap); 13168c2ecf20Sopenharmony_ci if (budget_ci->budget.dvb_frontend) { 13178c2ecf20Sopenharmony_ci budget_ci->budget.dvb_frontend->ops.tuner_ops.set_params = philips_su1278_tt_tuner_set_params; 13188c2ecf20Sopenharmony_ci break; 13198c2ecf20Sopenharmony_ci } 13208c2ecf20Sopenharmony_ci break; 13218c2ecf20Sopenharmony_ci 13228c2ecf20Sopenharmony_ci case 0x1010: // TT DVB-C CI budget (stv0297/Philips tdm1316l(tda6651tt)) 13238c2ecf20Sopenharmony_ci budget_ci->tuner_pll_address = 0x61; 13248c2ecf20Sopenharmony_ci budget_ci->budget.dvb_frontend = 13258c2ecf20Sopenharmony_ci dvb_attach(stv0297_attach, &dvbc_philips_tdm1316l_config, &budget_ci->budget.i2c_adap); 13268c2ecf20Sopenharmony_ci if (budget_ci->budget.dvb_frontend) { 13278c2ecf20Sopenharmony_ci budget_ci->budget.dvb_frontend->ops.tuner_ops.set_params = dvbc_philips_tdm1316l_tuner_set_params; 13288c2ecf20Sopenharmony_ci break; 13298c2ecf20Sopenharmony_ci } 13308c2ecf20Sopenharmony_ci break; 13318c2ecf20Sopenharmony_ci 13328c2ecf20Sopenharmony_ci case 0x1011: // Hauppauge/TT Nova-T budget (tda10045/Philips tdm1316l(tda6651tt) + TDA9889) 13338c2ecf20Sopenharmony_ci budget_ci->tuner_pll_address = 0x63; 13348c2ecf20Sopenharmony_ci budget_ci->budget.dvb_frontend = 13358c2ecf20Sopenharmony_ci dvb_attach(tda10045_attach, &philips_tdm1316l_config, &budget_ci->budget.i2c_adap); 13368c2ecf20Sopenharmony_ci if (budget_ci->budget.dvb_frontend) { 13378c2ecf20Sopenharmony_ci budget_ci->budget.dvb_frontend->ops.tuner_ops.init = philips_tdm1316l_tuner_init; 13388c2ecf20Sopenharmony_ci budget_ci->budget.dvb_frontend->ops.tuner_ops.set_params = philips_tdm1316l_tuner_set_params; 13398c2ecf20Sopenharmony_ci break; 13408c2ecf20Sopenharmony_ci } 13418c2ecf20Sopenharmony_ci break; 13428c2ecf20Sopenharmony_ci 13438c2ecf20Sopenharmony_ci case 0x1012: // TT DVB-T CI budget (tda10046/Philips tdm1316l(tda6651tt)) 13448c2ecf20Sopenharmony_ci budget_ci->tuner_pll_address = 0x60; 13458c2ecf20Sopenharmony_ci budget_ci->budget.dvb_frontend = 13468c2ecf20Sopenharmony_ci dvb_attach(tda10046_attach, &philips_tdm1316l_config_invert, &budget_ci->budget.i2c_adap); 13478c2ecf20Sopenharmony_ci if (budget_ci->budget.dvb_frontend) { 13488c2ecf20Sopenharmony_ci budget_ci->budget.dvb_frontend->ops.tuner_ops.init = philips_tdm1316l_tuner_init; 13498c2ecf20Sopenharmony_ci budget_ci->budget.dvb_frontend->ops.tuner_ops.set_params = philips_tdm1316l_tuner_set_params; 13508c2ecf20Sopenharmony_ci break; 13518c2ecf20Sopenharmony_ci } 13528c2ecf20Sopenharmony_ci break; 13538c2ecf20Sopenharmony_ci 13548c2ecf20Sopenharmony_ci case 0x1017: // TT S-1500 PCI 13558c2ecf20Sopenharmony_ci budget_ci->budget.dvb_frontend = dvb_attach(stv0299_attach, &alps_bsbe1_config, &budget_ci->budget.i2c_adap); 13568c2ecf20Sopenharmony_ci if (budget_ci->budget.dvb_frontend) { 13578c2ecf20Sopenharmony_ci budget_ci->budget.dvb_frontend->ops.tuner_ops.set_params = alps_bsbe1_tuner_set_params; 13588c2ecf20Sopenharmony_ci budget_ci->budget.dvb_frontend->tuner_priv = &budget_ci->budget.i2c_adap; 13598c2ecf20Sopenharmony_ci 13608c2ecf20Sopenharmony_ci budget_ci->budget.dvb_frontend->ops.dishnetwork_send_legacy_command = NULL; 13618c2ecf20Sopenharmony_ci if (dvb_attach(lnbp21_attach, budget_ci->budget.dvb_frontend, &budget_ci->budget.i2c_adap, LNBP21_LLC, 0) == NULL) { 13628c2ecf20Sopenharmony_ci printk("%s: No LNBP21 found!\n", __func__); 13638c2ecf20Sopenharmony_ci dvb_frontend_detach(budget_ci->budget.dvb_frontend); 13648c2ecf20Sopenharmony_ci budget_ci->budget.dvb_frontend = NULL; 13658c2ecf20Sopenharmony_ci } 13668c2ecf20Sopenharmony_ci } 13678c2ecf20Sopenharmony_ci break; 13688c2ecf20Sopenharmony_ci 13698c2ecf20Sopenharmony_ci case 0x101a: /* TT Budget-C-1501 (philips tda10023/philips tda8274A) */ 13708c2ecf20Sopenharmony_ci budget_ci->budget.dvb_frontend = dvb_attach(tda10023_attach, &tda10023_config, &budget_ci->budget.i2c_adap, 0x48); 13718c2ecf20Sopenharmony_ci if (budget_ci->budget.dvb_frontend) { 13728c2ecf20Sopenharmony_ci if (dvb_attach(tda827x_attach, budget_ci->budget.dvb_frontend, 0x61, &budget_ci->budget.i2c_adap, &tda827x_config) == NULL) { 13738c2ecf20Sopenharmony_ci printk(KERN_ERR "%s: No tda827x found!\n", __func__); 13748c2ecf20Sopenharmony_ci dvb_frontend_detach(budget_ci->budget.dvb_frontend); 13758c2ecf20Sopenharmony_ci budget_ci->budget.dvb_frontend = NULL; 13768c2ecf20Sopenharmony_ci } 13778c2ecf20Sopenharmony_ci } 13788c2ecf20Sopenharmony_ci break; 13798c2ecf20Sopenharmony_ci 13808c2ecf20Sopenharmony_ci case 0x101b: /* TT S-1500B (BSBE1-D01A - STV0288/STB6000/LNBP21) */ 13818c2ecf20Sopenharmony_ci budget_ci->budget.dvb_frontend = dvb_attach(stv0288_attach, &stv0288_bsbe1_d01a_config, &budget_ci->budget.i2c_adap); 13828c2ecf20Sopenharmony_ci if (budget_ci->budget.dvb_frontend) { 13838c2ecf20Sopenharmony_ci if (dvb_attach(stb6000_attach, budget_ci->budget.dvb_frontend, 0x63, &budget_ci->budget.i2c_adap)) { 13848c2ecf20Sopenharmony_ci if (!dvb_attach(lnbp21_attach, budget_ci->budget.dvb_frontend, &budget_ci->budget.i2c_adap, 0, 0)) { 13858c2ecf20Sopenharmony_ci printk(KERN_ERR "%s: No LNBP21 found!\n", __func__); 13868c2ecf20Sopenharmony_ci dvb_frontend_detach(budget_ci->budget.dvb_frontend); 13878c2ecf20Sopenharmony_ci budget_ci->budget.dvb_frontend = NULL; 13888c2ecf20Sopenharmony_ci } 13898c2ecf20Sopenharmony_ci } else { 13908c2ecf20Sopenharmony_ci printk(KERN_ERR "%s: No STB6000 found!\n", __func__); 13918c2ecf20Sopenharmony_ci dvb_frontend_detach(budget_ci->budget.dvb_frontend); 13928c2ecf20Sopenharmony_ci budget_ci->budget.dvb_frontend = NULL; 13938c2ecf20Sopenharmony_ci } 13948c2ecf20Sopenharmony_ci } 13958c2ecf20Sopenharmony_ci break; 13968c2ecf20Sopenharmony_ci 13978c2ecf20Sopenharmony_ci case 0x1019: // TT S2-3200 PCI 13988c2ecf20Sopenharmony_ci /* 13998c2ecf20Sopenharmony_ci * NOTE! on some STB0899 versions, the internal PLL takes a longer time 14008c2ecf20Sopenharmony_ci * to settle, aka LOCK. On the older revisions of the chip, we don't see 14018c2ecf20Sopenharmony_ci * this, as a result on the newer chips the entire clock tree, will not 14028c2ecf20Sopenharmony_ci * be stable after a freshly POWER 'ed up situation. 14038c2ecf20Sopenharmony_ci * In this case, we should RESET the STB0899 (Active LOW) and wait for 14048c2ecf20Sopenharmony_ci * PLL stabilization. 14058c2ecf20Sopenharmony_ci * 14068c2ecf20Sopenharmony_ci * On the TT S2 3200 and clones, the STB0899 demodulator's RESETB is 14078c2ecf20Sopenharmony_ci * connected to the SAA7146 GPIO, GPIO2, Pin 142 14088c2ecf20Sopenharmony_ci */ 14098c2ecf20Sopenharmony_ci /* Reset Demodulator */ 14108c2ecf20Sopenharmony_ci saa7146_setgpio(budget_ci->budget.dev, 2, SAA7146_GPIO_OUTLO); 14118c2ecf20Sopenharmony_ci /* Wait for everything to die */ 14128c2ecf20Sopenharmony_ci msleep(50); 14138c2ecf20Sopenharmony_ci /* Pull it up out of Reset state */ 14148c2ecf20Sopenharmony_ci saa7146_setgpio(budget_ci->budget.dev, 2, SAA7146_GPIO_OUTHI); 14158c2ecf20Sopenharmony_ci /* Wait for PLL to stabilize */ 14168c2ecf20Sopenharmony_ci msleep(250); 14178c2ecf20Sopenharmony_ci /* 14188c2ecf20Sopenharmony_ci * PLL state should be stable now. Ideally, we should check 14198c2ecf20Sopenharmony_ci * for PLL LOCK status. But well, never mind! 14208c2ecf20Sopenharmony_ci */ 14218c2ecf20Sopenharmony_ci budget_ci->budget.dvb_frontend = dvb_attach(stb0899_attach, &tt3200_config, &budget_ci->budget.i2c_adap); 14228c2ecf20Sopenharmony_ci if (budget_ci->budget.dvb_frontend) { 14238c2ecf20Sopenharmony_ci if (dvb_attach(stb6100_attach, budget_ci->budget.dvb_frontend, &tt3200_stb6100_config, &budget_ci->budget.i2c_adap)) { 14248c2ecf20Sopenharmony_ci if (!dvb_attach(lnbp21_attach, budget_ci->budget.dvb_frontend, &budget_ci->budget.i2c_adap, 0, 0)) { 14258c2ecf20Sopenharmony_ci printk("%s: No LNBP21 found!\n", __func__); 14268c2ecf20Sopenharmony_ci dvb_frontend_detach(budget_ci->budget.dvb_frontend); 14278c2ecf20Sopenharmony_ci budget_ci->budget.dvb_frontend = NULL; 14288c2ecf20Sopenharmony_ci } 14298c2ecf20Sopenharmony_ci } else { 14308c2ecf20Sopenharmony_ci dvb_frontend_detach(budget_ci->budget.dvb_frontend); 14318c2ecf20Sopenharmony_ci budget_ci->budget.dvb_frontend = NULL; 14328c2ecf20Sopenharmony_ci } 14338c2ecf20Sopenharmony_ci } 14348c2ecf20Sopenharmony_ci break; 14358c2ecf20Sopenharmony_ci 14368c2ecf20Sopenharmony_ci } 14378c2ecf20Sopenharmony_ci 14388c2ecf20Sopenharmony_ci if (budget_ci->budget.dvb_frontend == NULL) { 14398c2ecf20Sopenharmony_ci printk("budget-ci: A frontend driver was not found for device [%04x:%04x] subsystem [%04x:%04x]\n", 14408c2ecf20Sopenharmony_ci budget_ci->budget.dev->pci->vendor, 14418c2ecf20Sopenharmony_ci budget_ci->budget.dev->pci->device, 14428c2ecf20Sopenharmony_ci budget_ci->budget.dev->pci->subsystem_vendor, 14438c2ecf20Sopenharmony_ci budget_ci->budget.dev->pci->subsystem_device); 14448c2ecf20Sopenharmony_ci } else { 14458c2ecf20Sopenharmony_ci if (dvb_register_frontend 14468c2ecf20Sopenharmony_ci (&budget_ci->budget.dvb_adapter, budget_ci->budget.dvb_frontend)) { 14478c2ecf20Sopenharmony_ci printk("budget-ci: Frontend registration failed!\n"); 14488c2ecf20Sopenharmony_ci dvb_frontend_detach(budget_ci->budget.dvb_frontend); 14498c2ecf20Sopenharmony_ci budget_ci->budget.dvb_frontend = NULL; 14508c2ecf20Sopenharmony_ci } 14518c2ecf20Sopenharmony_ci } 14528c2ecf20Sopenharmony_ci} 14538c2ecf20Sopenharmony_ci 14548c2ecf20Sopenharmony_cistatic int budget_ci_attach(struct saa7146_dev *dev, struct saa7146_pci_extension_data *info) 14558c2ecf20Sopenharmony_ci{ 14568c2ecf20Sopenharmony_ci struct budget_ci *budget_ci; 14578c2ecf20Sopenharmony_ci int err; 14588c2ecf20Sopenharmony_ci 14598c2ecf20Sopenharmony_ci budget_ci = kzalloc(sizeof(struct budget_ci), GFP_KERNEL); 14608c2ecf20Sopenharmony_ci if (!budget_ci) { 14618c2ecf20Sopenharmony_ci err = -ENOMEM; 14628c2ecf20Sopenharmony_ci goto out1; 14638c2ecf20Sopenharmony_ci } 14648c2ecf20Sopenharmony_ci 14658c2ecf20Sopenharmony_ci dprintk(2, "budget_ci: %p\n", budget_ci); 14668c2ecf20Sopenharmony_ci 14678c2ecf20Sopenharmony_ci dev->ext_priv = budget_ci; 14688c2ecf20Sopenharmony_ci 14698c2ecf20Sopenharmony_ci err = ttpci_budget_init(&budget_ci->budget, dev, info, THIS_MODULE, 14708c2ecf20Sopenharmony_ci adapter_nr); 14718c2ecf20Sopenharmony_ci if (err) 14728c2ecf20Sopenharmony_ci goto out2; 14738c2ecf20Sopenharmony_ci 14748c2ecf20Sopenharmony_ci err = msp430_ir_init(budget_ci); 14758c2ecf20Sopenharmony_ci if (err) 14768c2ecf20Sopenharmony_ci goto out3; 14778c2ecf20Sopenharmony_ci 14788c2ecf20Sopenharmony_ci ciintf_init(budget_ci); 14798c2ecf20Sopenharmony_ci 14808c2ecf20Sopenharmony_ci budget_ci->budget.dvb_adapter.priv = budget_ci; 14818c2ecf20Sopenharmony_ci frontend_init(budget_ci); 14828c2ecf20Sopenharmony_ci 14838c2ecf20Sopenharmony_ci ttpci_budget_init_hooks(&budget_ci->budget); 14848c2ecf20Sopenharmony_ci 14858c2ecf20Sopenharmony_ci return 0; 14868c2ecf20Sopenharmony_ci 14878c2ecf20Sopenharmony_ciout3: 14888c2ecf20Sopenharmony_ci ttpci_budget_deinit(&budget_ci->budget); 14898c2ecf20Sopenharmony_ciout2: 14908c2ecf20Sopenharmony_ci kfree(budget_ci); 14918c2ecf20Sopenharmony_ciout1: 14928c2ecf20Sopenharmony_ci return err; 14938c2ecf20Sopenharmony_ci} 14948c2ecf20Sopenharmony_ci 14958c2ecf20Sopenharmony_cistatic int budget_ci_detach(struct saa7146_dev *dev) 14968c2ecf20Sopenharmony_ci{ 14978c2ecf20Sopenharmony_ci struct budget_ci *budget_ci = (struct budget_ci *) dev->ext_priv; 14988c2ecf20Sopenharmony_ci struct saa7146_dev *saa = budget_ci->budget.dev; 14998c2ecf20Sopenharmony_ci int err; 15008c2ecf20Sopenharmony_ci 15018c2ecf20Sopenharmony_ci if (budget_ci->budget.ci_present) 15028c2ecf20Sopenharmony_ci ciintf_deinit(budget_ci); 15038c2ecf20Sopenharmony_ci msp430_ir_deinit(budget_ci); 15048c2ecf20Sopenharmony_ci if (budget_ci->budget.dvb_frontend) { 15058c2ecf20Sopenharmony_ci dvb_unregister_frontend(budget_ci->budget.dvb_frontend); 15068c2ecf20Sopenharmony_ci dvb_frontend_detach(budget_ci->budget.dvb_frontend); 15078c2ecf20Sopenharmony_ci } 15088c2ecf20Sopenharmony_ci err = ttpci_budget_deinit(&budget_ci->budget); 15098c2ecf20Sopenharmony_ci 15108c2ecf20Sopenharmony_ci // disable frontend and CI interface 15118c2ecf20Sopenharmony_ci saa7146_setgpio(saa, 2, SAA7146_GPIO_INPUT); 15128c2ecf20Sopenharmony_ci 15138c2ecf20Sopenharmony_ci kfree(budget_ci); 15148c2ecf20Sopenharmony_ci 15158c2ecf20Sopenharmony_ci return err; 15168c2ecf20Sopenharmony_ci} 15178c2ecf20Sopenharmony_ci 15188c2ecf20Sopenharmony_cistatic struct saa7146_extension budget_extension; 15198c2ecf20Sopenharmony_ci 15208c2ecf20Sopenharmony_ciMAKE_BUDGET_INFO(ttbs2, "TT-Budget/S-1500 PCI", BUDGET_TT); 15218c2ecf20Sopenharmony_ciMAKE_BUDGET_INFO(ttbci, "TT-Budget/WinTV-NOVA-CI PCI", BUDGET_TT_HW_DISEQC); 15228c2ecf20Sopenharmony_ciMAKE_BUDGET_INFO(ttbt2, "TT-Budget/WinTV-NOVA-T PCI", BUDGET_TT); 15238c2ecf20Sopenharmony_ciMAKE_BUDGET_INFO(ttbtci, "TT-Budget-T-CI PCI", BUDGET_TT); 15248c2ecf20Sopenharmony_ciMAKE_BUDGET_INFO(ttbcci, "TT-Budget-C-CI PCI", BUDGET_TT); 15258c2ecf20Sopenharmony_ciMAKE_BUDGET_INFO(ttc1501, "TT-Budget C-1501 PCI", BUDGET_TT); 15268c2ecf20Sopenharmony_ciMAKE_BUDGET_INFO(tt3200, "TT-Budget S2-3200 PCI", BUDGET_TT); 15278c2ecf20Sopenharmony_ciMAKE_BUDGET_INFO(ttbs1500b, "TT-Budget S-1500B PCI", BUDGET_TT); 15288c2ecf20Sopenharmony_ci 15298c2ecf20Sopenharmony_cistatic const struct pci_device_id pci_tbl[] = { 15308c2ecf20Sopenharmony_ci MAKE_EXTENSION_PCI(ttbci, 0x13c2, 0x100c), 15318c2ecf20Sopenharmony_ci MAKE_EXTENSION_PCI(ttbci, 0x13c2, 0x100f), 15328c2ecf20Sopenharmony_ci MAKE_EXTENSION_PCI(ttbcci, 0x13c2, 0x1010), 15338c2ecf20Sopenharmony_ci MAKE_EXTENSION_PCI(ttbt2, 0x13c2, 0x1011), 15348c2ecf20Sopenharmony_ci MAKE_EXTENSION_PCI(ttbtci, 0x13c2, 0x1012), 15358c2ecf20Sopenharmony_ci MAKE_EXTENSION_PCI(ttbs2, 0x13c2, 0x1017), 15368c2ecf20Sopenharmony_ci MAKE_EXTENSION_PCI(ttc1501, 0x13c2, 0x101a), 15378c2ecf20Sopenharmony_ci MAKE_EXTENSION_PCI(tt3200, 0x13c2, 0x1019), 15388c2ecf20Sopenharmony_ci MAKE_EXTENSION_PCI(ttbs1500b, 0x13c2, 0x101b), 15398c2ecf20Sopenharmony_ci { 15408c2ecf20Sopenharmony_ci .vendor = 0, 15418c2ecf20Sopenharmony_ci } 15428c2ecf20Sopenharmony_ci}; 15438c2ecf20Sopenharmony_ci 15448c2ecf20Sopenharmony_ciMODULE_DEVICE_TABLE(pci, pci_tbl); 15458c2ecf20Sopenharmony_ci 15468c2ecf20Sopenharmony_cistatic struct saa7146_extension budget_extension = { 15478c2ecf20Sopenharmony_ci .name = "budget_ci dvb", 15488c2ecf20Sopenharmony_ci .flags = SAA7146_USE_I2C_IRQ, 15498c2ecf20Sopenharmony_ci 15508c2ecf20Sopenharmony_ci .module = THIS_MODULE, 15518c2ecf20Sopenharmony_ci .pci_tbl = &pci_tbl[0], 15528c2ecf20Sopenharmony_ci .attach = budget_ci_attach, 15538c2ecf20Sopenharmony_ci .detach = budget_ci_detach, 15548c2ecf20Sopenharmony_ci 15558c2ecf20Sopenharmony_ci .irq_mask = MASK_03 | MASK_06 | MASK_10, 15568c2ecf20Sopenharmony_ci .irq_func = budget_ci_irq, 15578c2ecf20Sopenharmony_ci}; 15588c2ecf20Sopenharmony_ci 15598c2ecf20Sopenharmony_cistatic int __init budget_ci_init(void) 15608c2ecf20Sopenharmony_ci{ 15618c2ecf20Sopenharmony_ci return saa7146_register_extension(&budget_extension); 15628c2ecf20Sopenharmony_ci} 15638c2ecf20Sopenharmony_ci 15648c2ecf20Sopenharmony_cistatic void __exit budget_ci_exit(void) 15658c2ecf20Sopenharmony_ci{ 15668c2ecf20Sopenharmony_ci saa7146_unregister_extension(&budget_extension); 15678c2ecf20Sopenharmony_ci} 15688c2ecf20Sopenharmony_ci 15698c2ecf20Sopenharmony_cimodule_init(budget_ci_init); 15708c2ecf20Sopenharmony_cimodule_exit(budget_ci_exit); 15718c2ecf20Sopenharmony_ci 15728c2ecf20Sopenharmony_ciMODULE_LICENSE("GPL"); 15738c2ecf20Sopenharmony_ciMODULE_AUTHOR("Michael Hunold, Jack Thomasson, Andrew de Quincey, others"); 15748c2ecf20Sopenharmony_ciMODULE_DESCRIPTION("driver for the SAA7146 based so-called budget PCI DVB cards w/ CI-module produced by Siemens, Technotrend, Hauppauge"); 1575