{"thread":{"id":"35837","subject":"[PATCH] saa7134: Add support for SnaZio TvPVR PRO","startedAt":"2014-02-09T16:11:59Z","lastAt":"2014-02-09T16:11:59Z","messageCount":1,"participants":["POJAR GEORGE"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"234550","messageId":"1391962319-4120-1-git-send-email-user@george","threadId":"35837","inReplyTo":null,"subject":"[PATCH] saa7134: Add support for SnaZio TvPVR PRO","fromName":"POJAR GEORGE","fromEmail":"geoubuntu@gmail.com","sentAt":"2014-02-09T16:11:59Z","receivedAt":"2014-02-09T16:11:59Z","isPatch":true,"sender":{"key":"geoubuntu@gmail.com","avatar":null},"body":"From: POJAR GEORGE <geoubuntu@gmail.com>\n\nSigned-off-by: POJAR GEORGE <geoubuntu@gmail.com>\n---\n Documentation/video4linux/CARDLIST.saa7134     |   1 +\n drivers/media/pci/saa7134/saa7134-cards.c      |  51 ++++++++++-\n drivers/media/pci/saa7134/saa7134-input.c      |  62 +++++++++++++\n drivers/media/pci/saa7134/saa7134.h            |   1 +\n drivers/media/rc/keymaps/Makefile              |   1 +\n drivers/media/rc/keymaps/rc-snazio-tvpvr-pro.c | 116 +++++++++++++++++++++++++\n include/media/rc-map.h                         |   1 +\n 7 files changed, 232 insertions(+), 1 deletion(-)\n create mode 100644 drivers/media/rc/keymaps/rc-snazio-tvpvr-pro.c\n\ndiff --git a/Documentation/video4linux/CARDLIST.saa7134 b/Documentation/video4linux/CARDLIST.saa7134\nindex 8df17d0..32e4353 100644\n--- a/Documentation/video4linux/CARDLIST.saa7134\n+++ b/Documentation/video4linux/CARDLIST.saa7134\n@@ -191,3 +191,4 @@\n 190 -> Asus My Cinema PS3-100                   [1043:48cd]\n 191 -> Hawell HW-9004V1\n 192 -> AverMedia AverTV Satellite Hybrid+FM A706 [1461:2055]\n+193 -> SnaZio TvPVR PRO                         [0x1779:0x13cf,0x1779:0x13d0,0x1779:0x13d1]\ndiff --git a/drivers/media/pci/saa7134/saa7134-cards.c b/drivers/media/pci/saa7134/saa7134-cards.c\nindex d45e7f6..3476785 100644\n--- a/drivers/media/pci/saa7134/saa7134-cards.c\n+++ b/drivers/media/pci/saa7134/saa7134-cards.c\n@@ -5827,7 +5827,37 @@ struct saa7134_board saa7134_boards[] = {\n \t\t\t.gpio = 0x0000800,\n \t\t},\n \t},\n-\n+\t[SAA7134_BOARD_SNAZIO_TVPVR_PRO] = {\n+\t\t.name           = \"SnaZio TvPVR PRO\",\n+\t\t.audio_clock    = 0x00187de7,\n+\t\t.tuner_type     = TUNER_PHILIPS_TDA8290,\n+\t\t.radio_type     = UNSET,\n+\t\t.tuner_addr     = ADDR_UNSET,\n+\t\t.radio_addr     = ADDR_UNSET,\n+\t\t.gpiomask       = 1 << 21,\n+\t\t.inputs         = {{\n+\t\t\t.name = name_tv,\n+\t\t\t.vmux = 1,\n+\t\t\t.amux = TV,\n+\t\t\t.gpio = 0x0000000,\n+\t\t\t.tv   = 1,\n+\t\t}, {\n+\t\t\t.name = name_comp1,     /* Composite input */\n+\t\t\t.vmux = 3,\n+\t\t\t.amux = LINE2,\n+\t\t\t.gpio = 0x0000000,\n+\t\t}, {\n+\t\t\t.name = name_svideo,    /* S-Video input */\n+\t\t\t.vmux = 8,\n+\t\t\t.amux = LINE2,\n+\t\t\t.gpio = 0x0000000,\n+\t\t} },\n+\t\t.radio = {\n+\t\t\t.name = name_radio,\n+\t\t\t.amux = TV,\n+\t\t\t.gpio = 0x0200000,\n+\t\t},\n+\t},\n };\n \n const unsigned int saa7134_bcount = ARRAY_SIZE(saa7134_boards);\n@@ -7080,6 +7110,24 @@ struct pci_device_id saa7134_pci_tbl[] = {\n \t\t.subdevice    = 0x2055, /* AverTV Satellite Hybrid+FM A706 */\n \t\t.driver_data  = SAA7134_BOARD_AVERMEDIA_A706,\n \t}, {\n+\t\t.vendor       = PCI_VENDOR_ID_PHILIPS,\n+\t\t.device       = PCI_DEVICE_ID_PHILIPS_SAA7133,\n+\t\t.subvendor    = 0x1779,\n+\t\t.subdevice    = 0x13cf,\n+\t\t.driver_data  = SAA7134_BOARD_SNAZIO_TVPVR_PRO,\n+\t}, {\n+\t\t.vendor       = PCI_VENDOR_ID_PHILIPS,\n+\t\t.device       = PCI_DEVICE_ID_PHILIPS_SAA7133,\n+\t\t.subvendor    = 0x1779,\n+\t\t.subdevice    = 0x13d0,\n+\t\t.driver_data  = SAA7134_BOARD_SNAZIO_TVPVR_PRO,\n+\t}, {\n+\t\t.vendor       = PCI_VENDOR_ID_PHILIPS,\n+\t\t.device       = PCI_DEVICE_ID_PHILIPS_SAA7133,\n+\t\t.subvendor    = 0x1779,\n+\t\t.subdevice    = 0x13d1,\n+\t\t.driver_data  = SAA7134_BOARD_SNAZIO_TVPVR_PRO,\n+\t}, {\n \t\t/* --- boards without eeprom + subsystem ID --- */\n \t\t.vendor       = PCI_VENDOR_ID_PHILIPS,\n \t\t.device       = PCI_DEVICE_ID_PHILIPS_SAA7134,\n@@ -7608,6 +7656,7 @@ int saa7134_board_init1(struct saa7134_dev *dev)\n \tcase SAA7134_BOARD_BEHOLD_H7:\n \tcase SAA7134_BOARD_BEHOLD_A7:\n \tcase SAA7134_BOARD_KWORLD_PC150U:\n+\tcase SAA7134_BOARD_SNAZIO_TVPVR_PRO:\n \t\tdev->has_remote = SAA7134_REMOTE_I2C;\n \t\tbreak;\n \tcase SAA7134_BOARD_AVERMEDIA_A169_B:\ndiff --git a/drivers/media/pci/saa7134/saa7134-input.c b/drivers/media/pci/saa7134/saa7134-input.c\nindex 6f43126..62ccc7d 100644\n--- a/drivers/media/pci/saa7134/saa7134-input.c\n+++ b/drivers/media/pci/saa7134/saa7134-input.c\n@@ -416,6 +416,53 @@ static int get_key_pinnacle_color(struct IR_i2c *ir, u32 *ir_key, u32 *ir_raw)\n \treturn get_key_pinnacle(ir, ir_key, ir_raw, 2, 0x80, 0x88);\n }\n \n+/* copied and modified from get_key_msi_tvanywhere_plus() */\n+static int get_key_snazio_tvpvr_pro(struct IR_i2c *ir, u32 *ir_key, u32 *ir_raw)\n+{\n+\tunsigned char b;\n+\tunsigned int gpio;\n+\n+\t/* <dev> is needed to access GPIO. Used by the saa_readl macro. */\n+\tstruct saa7134_dev *dev = ir->c->adapter->algo_data;\n+\tif (dev == NULL) {\n+\t\ti2cdprintk(\"get_key_snazio_tvpvr_pro: \"\n+\t\t\t   \"ir->c->adapter->algo_data is NULL!\\n\");\n+\t\treturn -EIO;\n+\t}\n+\n+\t/* rising SAA7134_GPIO_GPRESCAN reads the status */\n+\n+\tsaa_clearb(SAA7134_GPIO_GPMODE3, SAA7134_GPIO_GPRESCAN);\n+\tsaa_setb(SAA7134_GPIO_GPMODE3, SAA7134_GPIO_GPRESCAN);\n+\n+\tgpio = saa_readl(SAA7134_GPIO_GPSTATUS0 >> 2);\n+\n+\t/* GPIO&0x100 is pulsed low when a button is pressed. Don't do\n+\t   I2C receive if gpio&0x100 is not low. */\n+\n+\tif (gpio & 0x100)\n+\t\treturn 0;       /* No button press */\n+\n+\t/* GPIO says there is a button press. Get it. */\n+\n+\tif (1 != i2c_master_recv(ir->c, &b, 1)) {\n+\t\ti2cdprintk(\"read error\\n\");\n+\t\treturn -EIO;\n+\t}\n+\n+\t/* No button press */\n+\n+\tif (b == 0xff)\n+\t\treturn 0;\n+\n+\t/* Button pressed */\n+\n+\tdprintk(\"get_key_snazio_tvpvr_pro: Key = 0x%02X\\n\", b);\n+\t*ir_key = b;\n+\t*ir_raw = b;\n+\treturn 1;\n+}\n+\n void saa7134_input_irq(struct saa7134_dev *dev)\n {\n \tstruct saa7134_card_ir *ir;\n@@ -1006,6 +1053,21 @@ void saa7134_probe_i2c_ir(struct saa7134_dev *dev)\n \t\tdev->init_data.ir_codes = RC_MAP_FLYDVB;\n \t\tinfo.addr = 0x0b;\n \t\tbreak;\n+\tcase SAA7134_BOARD_SNAZIO_TVPVR_PRO:\n+\t\t/* copied and modified from MSI TV@nywhere Plus */\n+\t\tdev->init_data.name = \"SnaZio TvPVR PRO\";\n+\t\tdev->init_data.get_key = get_key_snazio_tvpvr_pro;\n+\t\tdev->init_data.ir_codes = RC_MAP_SNAZIO_TVPVR_PRO;\n+\t\tinfo.addr = 0x30;\n+\t\t/* MSI TV@nywhere Plus controller doesn't seem to\n+\t\t   respond to probes unless we read something from\n+\t\t   an existing device. Weird...\n+\t\t   REVISIT: might no longer be needed */\n+\t\trc = i2c_transfer(&dev->i2c_adap, &msg_msi, 1);\n+\t\tdprintk(\"probe 0x%02x @ %s: %s\\n\",\n+\t\t\tmsg_msi.addr, dev->i2c_adap.name,\n+\t\t\t(1 == rc) ? \"yes\" : \"no\");\n+\t\tbreak;\n \tdefault:\n \t\tdprintk(\"No I2C IR support for board %x\\n\", dev->board);\n \t\treturn;\ndiff --git a/drivers/media/pci/saa7134/saa7134.h b/drivers/media/pci/saa7134/saa7134.h\nindex 2474e84..28b083f 100644\n--- a/drivers/media/pci/saa7134/saa7134.h\n+++ b/drivers/media/pci/saa7134/saa7134.h\n@@ -338,6 +338,7 @@ struct saa7134_card_ir {\n #define SAA7134_BOARD_ASUSTeK_PS3_100      190\n #define SAA7134_BOARD_HAWELL_HW_9004V1      191\n #define SAA7134_BOARD_AVERMEDIA_A706\t\t192\n+#define SAA7134_BOARD_SNAZIO_TVPVR_PRO      193\n \n #define SAA7134_MAXBOARDS 32\n #define SAA7134_INPUT_MAX 8\ndiff --git a/drivers/media/rc/keymaps/Makefile b/drivers/media/rc/keymaps/Makefile\nindex 0b8c549..72b2e45 100644\n--- a/drivers/media/rc/keymaps/Makefile\n+++ b/drivers/media/rc/keymaps/Makefile\n@@ -81,6 +81,7 @@ obj-$(CONFIG_RC_MAP) += rc-adstech-dvb-t-pci.o \\\n \t\t\trc-real-audio-220-32-keys.o \\\n \t\t\trc-reddo.o \\\n \t\t\trc-snapstream-firefly.o \\\n+\t\t\trc-snazio-tvpvr-pro.o \\\n \t\t\trc-streamzap.o \\\n \t\t\trc-tbs-nec.o \\\n \t\t\trc-technisat-usb2.o \\\ndiff --git a/drivers/media/rc/keymaps/rc-snazio-tvpvr-pro.c b/drivers/media/rc/keymaps/rc-snazio-tvpvr-pro.c\nnew file mode 100644\nindex 0000000..127350e\n--- /dev/null\n+++ b/drivers/media/rc/keymaps/rc-snazio-tvpvr-pro.c\n@@ -0,0 +1,116 @@\n+/* rc-snazio-tvpvr-pro.h - Keytable for snazio_tvpvr_pro Remote Controller\n+ *\n+ * keymap imported from ir-keymaps.c\n+ *\n+ * Copyright (c) 2010 by Mauro Carvalho Chehab\n+ * Copyright (c) 2010 by POJAR GEORGE <geoubuntu@gmail.com>\n+ *\n+ * This program is free software; you can redistribute it and/or modify\n+ * it under the terms of the GNU General Public License as published by\n+ * the Free Software Foundation; either version 2 of the License, or\n+ * (at your option) any later version.\n+ */\n+\n+#include <media/rc-map.h>\n+#include <linux/module.h>\n+\n+/*\n+  Keycodes for remote on the SnaZio TvPVR PRO.\n+  POJAR GEORGE <geoubuntu@gmail.com>\n+*/\n+\n+static struct rc_map_table snazio_tvpvr_pro[] = {\n+\n+/*  ---- Remote Button Layout ----\n+\n+    POWER   SOURCE  SCAN    MUTE\n+    TV/FM   1       2       3\n+    |>      4       5       6\n+    <|      7       8       9\n+    ^^UP    0       +       RECALL\n+    vvDN    RECORD  STOP    PLAY\n+\n+\tMINIMIZE          ZOOM\n+\n+\t\t  CH+\n+      VOL-                   VOL+\n+\t\t  CH-\n+\n+\tSNAPSHOT           MTS\n+\n+     <<      FUNC    >>     RESET\n+*/\n+\n+\t{ 0x01, KEY_1 },\t\t/* 1 */\n+\t{ 0x0b, KEY_2 },\t\t/* 2 */\n+\t{ 0x1b, KEY_3 },\t\t/* 3 */\n+\t{ 0x05, KEY_4 },\t\t/* 4 */\n+\t{ 0x09, KEY_5 },\t\t/* 5 */\n+\t{ 0x15, KEY_6 },\t\t/* 6 */\n+\t{ 0x06, KEY_7 },\t\t/* 7 */\n+\t{ 0x0a, KEY_8 },\t\t/* 8 */\n+\t{ 0x12, KEY_9 },\t\t/* 9 */\n+\t{ 0x02, KEY_0 },\t\t/* 0 */\n+\t{ 0x10, KEY_KPPLUS },\t\t/* + */\n+\t{ 0x13, KEY_AGAIN },\t\t/* Recall */\n+\n+\t{ 0x1e, KEY_POWER },\t\t/* Power */\n+\t{ 0x07, KEY_VIDEO },\t\t/* Source */\n+\t{ 0x1c, KEY_SEARCH },\t\t/* Scan */\n+\t{ 0x18, KEY_MUTE },\t\t/* Mute */\n+\n+\t{ 0x03, KEY_RADIO },\t\t/* TV/FM */\n+\t/* The next four keys are duplicates that appear to send the\n+\t   same IR code as Ch+, Ch-, >>, and << .  The raw code assigned\n+\t   to them is the actual code + 0x20 - they will never be\n+\t   detected as such unless some way is discovered to distinguish\n+\t   these buttons from those that have the same code. */\n+\t{ 0x3f, KEY_RIGHT },\t\t/* |> and Ch+ */\n+\t{ 0x37, KEY_LEFT },\t\t/* <| and Ch- */\n+\t{ 0x2c, KEY_UP },\t\t/* ^^Up and >> */\n+\t{ 0x24, KEY_DOWN },\t\t/* vvDn and << */\n+\n+\t{ 0x00, KEY_RECORD },\t\t/* Record */\n+\t{ 0x08, KEY_STOP },\t\t/* Stop */\n+\t{ 0x11, KEY_PLAY },\t\t/* Play */\n+\n+\t{ 0x0f, KEY_CLOSE },\t\t/* Minimize */\n+\t{ 0x19, KEY_ZOOM },\t\t/* Zoom */\n+\t{ 0x1a, KEY_CAMERA },\t\t/* Snapshot */\n+\t{ 0x0d, KEY_LANGUAGE },\t\t/* MTS */\n+\n+\t{ 0x14, KEY_VOLUMEDOWN },\t/* Vol- */\n+\t{ 0x16, KEY_VOLUMEUP },\t\t/* Vol+ */\n+\t{ 0x17, KEY_CHANNELDOWN },\t/* Ch- */\n+\t{ 0x1f, KEY_CHANNELUP },\t/* Ch+ */\n+\n+\t{ 0x04, KEY_REWIND },\t\t/* << */\n+\t{ 0x0e, KEY_MENU },\t\t/* Function */\n+\t{ 0x0c, KEY_FASTFORWARD },\t/* >> */\n+\t{ 0x1d, KEY_RESTART },\t\t/* Reset */\n+};\n+\n+static struct rc_map_list snazio_tvpvr_pro_map = {\n+\t.map = {\n+\t\t.scan    = snazio_tvpvr_pro,\n+\t\t.size    = ARRAY_SIZE(snazio_tvpvr_pro),\n+\t\t.rc_type = RC_TYPE_UNKNOWN,\t/* Legacy IR type */\n+\t\t.name    = RC_MAP_SNAZIO_TVPVR_PRO,\n+\t}\n+};\n+\n+static int int __init init_rc_map_snazio_tvpvr_pro(void)\n+{\n+\treturn rc_map_register(&snazio_tvpvr_pro_map);\n+}\n+\n+static void __exit exit_rc_map_snazio_tvpvr_pro(void)\n+{\n+\trc_map_unregister(&snazio_tvpvr_pro_map);\n+}\n+\n+module_init(init_rc_map_snazio_tvpvr_pro)\n+module_exit(exit_rc_map_snazio_tvpvr_pro)\n+\n+MODULE_LICENSE(\"GPL\");\n+MODULE_AUTHOR(\"POJAR GEORGE <geoubuntu@gmail.com>\");\ndiff --git a/include/media/rc-map.h b/include/media/rc-map.h\nindex e5aa240..b802af4 100644\n--- a/include/media/rc-map.h\n+++ b/include/media/rc-map.h\n@@ -177,6 +177,7 @@ void rc_map_init(void);\n #define RC_MAP_REAL_AUDIO_220_32_KEYS    \"rc-real-audio-220-32-keys\"\n #define RC_MAP_REDDO                     \"rc-reddo\"\n #define RC_MAP_SNAPSTREAM_FIREFLY        \"rc-snapstream-firefly\"\n+#define RC_MAP_SNAZIO_TVPVR_PRO          \"rc-snazio-tvpvr-pro\"\n #define RC_MAP_STREAMZAP                 \"rc-streamzap\"\n #define RC_MAP_TBS_NEC                   \"rc-tbs-nec\"\n #define RC_MAP_TECHNISAT_USB2            \"rc-technisat-usb2\"\n-- \n1.9.rc1\n"}]}