From patchwork Sat Jun 26 11:09:34 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Nagarajan, Rajkumar" X-Patchwork-Id: 108203 X-Patchwork-Delegate: tomi.valkeinen@nokia.com Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.4/8.14.3) with ESMTP id o5QB9kit015038 for ; Sat, 26 Jun 2010 11:09:46 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753453Ab0FZLJo (ORCPT ); Sat, 26 Jun 2010 07:09:44 -0400 Received: from arroyo.ext.ti.com ([192.94.94.40]:42228 "EHLO arroyo.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753275Ab0FZLJm convert rfc822-to-8bit (ORCPT ); Sat, 26 Jun 2010 07:09:42 -0400 Received: from dbdp20.itg.ti.com ([172.24.170.38]) by arroyo.ext.ti.com (8.13.7/8.13.7) with ESMTP id o5QB9aTg016882 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Sat, 26 Jun 2010 06:09:39 -0500 Received: from dbde71.ent.ti.com (localhost [127.0.0.1]) by dbdp20.itg.ti.com (8.13.8/8.13.8) with ESMTP id o5QB9ZF3005878; Sat, 26 Jun 2010 16:39:35 +0530 (IST) Received: from dbde02.ent.ti.com ([172.24.170.145]) by dbde71.ent.ti.com ([172.24.170.149]) with mapi; Sat, 26 Jun 2010 16:39:36 +0530 From: "Nagarajan, Rajkumar" To: "linux-omap@vger.kernel.org" CC: "tomi.valkeinen@nokia.com" , "linux-fbdev@vger.kernel.org" Date: Sat, 26 Jun 2010 16:39:34 +0530 Subject: [PATCH] OMAP:DSS: Enable TV Detection support Thread-Topic: [PATCH] OMAP:DSS: Enable TV Detection support Thread-Index: AcsVIQ5X3ipy6I9/QimfWs2YMA5yJw== Message-ID: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: acceptlanguage: en-US MIME-Version: 1.0 Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter.kernel.org [140.211.167.41]); Sat, 26 Jun 2010 11:09:46 +0000 (UTC) diff --git a/arch/arm/plat-omap/include/plat/display.h b/arch/arm/plat-omap/include/plat/display.h index 7842efa..522240b 100644 --- a/arch/arm/plat-omap/include/plat/display.h +++ b/arch/arm/plat-omap/include/plat/display.h @@ -464,6 +464,8 @@ struct omap_dss_device { enum omap_dss_display_state state; + u32 (*get_device_state)(struct omap_dss_device *dssdev); + /* platform specific */ int (*platform_enable)(struct omap_dss_device *dssdev); void (*platform_disable)(struct omap_dss_device *dssdev); diff --git a/drivers/video/omap2/dss/display.c b/drivers/video/omap2/dss/display.c index ef8c852..2b937fe 100644 --- a/drivers/video/omap2/dss/display.c +++ b/drivers/video/omap2/dss/display.c @@ -278,6 +278,26 @@ static ssize_t display_wss_store(struct device *dev, return size; } +static ssize_t device_state_show(struct device *dev, + struct device_attribute *attr, char *buf) +{ + struct omap_dss_device *dssdev = to_dss_device(dev); + unsigned int device_state; + + if (!dssdev->get_device_state) + return -ENOENT; + + device_state = dssdev->get_device_state(dssdev); + + return snprintf(buf, PAGE_SIZE, "%u\n", device_state); +} + +static ssize_t device_state_store(struct device *dev, + struct device_attribute *attr, const char *buf, size_t size) +{ + return size; +} + static DEVICE_ATTR(enabled, S_IRUGO|S_IWUSR, display_enabled_show, display_enabled_store); static DEVICE_ATTR(update_mode, S_IRUGO|S_IWUSR, @@ -290,6 +310,8 @@ static DEVICE_ATTR(rotate, S_IRUGO|S_IWUSR, display_rotate_show, display_rotate_store); static DEVICE_ATTR(mirror, S_IRUGO|S_IWUSR, display_mirror_show, display_mirror_store); +static DEVICE_ATTR(device_state, S_IRUGO|S_IWUSR, + device_state_show, device_state_store); static DEVICE_ATTR(wss, S_IRUGO|S_IWUSR, display_wss_show, display_wss_store); @@ -301,6 +323,7 @@ static struct device_attribute *display_sysfs_attrs[] = { &dev_attr_rotate, &dev_attr_mirror, &dev_attr_wss, + &dev_attr_device_state, NULL }; diff --git a/drivers/video/omap2/dss/venc.c b/drivers/video/omap2/dss/venc.c index eff3505..3b5093b 100644 --- a/drivers/video/omap2/dss/venc.c +++ b/drivers/video/omap2/dss/venc.c @@ -33,12 +33,15 @@ #include #include #include +#include #include #include #include "dss.h" +#define TV_INT_GPIO 33 +#define TV_DETECT_DELAY 40 /*Delay for TV detection logic*/ #define VENC_BASE 0x48050C00 /* Venc registers */ @@ -612,6 +615,46 @@ static int venc_set_wss(struct omap_dss_device *dssdev, u32 wss) return 0; } +/** + * Enables TVDET pulse generation + */ +static void venc_enable_tv_detect(void) +{ + u32 l; + + l = venc_read_reg(VENC_GEN_CTRL); + /* TVDET Active High Setting */ + l |= FLD_VAL(1, 16, 16); + /* Enable TVDET pulse generation */ + l |= FLD_VAL(1, 0, 0); + venc_write_reg(VENC_GEN_CTRL, l); +} + +/** + * Disables TVDET pulse generation + */ +static void venc_disable_tv_detect(void) +{ + u32 l; + + /* Disable TVDET pulse generation */ + l = venc_read_reg(VENC_GEN_CTRL); + l |= FLD_VAL(0, 0, 0); + venc_write_reg(VENC_GEN_CTRL, l); +} + +static u32 venc_detect_device(struct omap_dss_device *dssdev) +{ + u32 tv_state; + + venc_enable_tv_detect(); + mdelay(TV_DETECT_DELAY); + tv_state = gpio_get_value(TV_INT_GPIO); + venc_disable_tv_detect(); + + return tv_state; +} + static struct omap_dss_driver venc_driver = { .probe = venc_panel_probe, .remove = venc_panel_remove, @@ -646,6 +689,7 @@ static struct omap_dss_driver venc_driver = { int venc_init(struct platform_device *pdev) { u8 rev_id; + int ret; mutex_init(&venc.venc_lock); @@ -671,7 +715,14 @@ int venc_init(struct platform_device *pdev) venc_enable_clocks(0); + ret = gpio_request(TV_INT_GPIO, "tv_detect"); + if (ret) + pr_err("Failed to get TV_INT_GPIO gpio_33.\n"); + else + gpio_direction_input(TV_INT_GPIO); + return omap_dss_register_driver(&venc_driver); + } void venc_exit(void) @@ -684,6 +735,7 @@ void venc_exit(void) int venc_init_display(struct omap_dss_device *dssdev) { DSSDBG("init_display\n"); + dssdev->get_device_state = venc_detect_device; return 0; }