From patchwork Fri Jun 2 12:18:14 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dave Stevenson X-Patchwork-Id: 41609 X-Patchwork-Delegate: hverkuil@xs4all.nl Received: from mail.tu-berlin.de ([130.149.7.33]) by www.linuxtv.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dGlXz-0000pg-Jj; Fri, 02 Jun 2017 12:19:19 +0000 X-tubIT-Incoming-IP: 209.132.180.67 Received: from vger.kernel.org ([209.132.180.67]) by mail.tu-berlin.de (exim-4.89/mailfrontend-6) with esmtp id 1dGlXx-0000M3-40; Fri, 02 Jun 2017 14:19:19 +0200 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751264AbdFBMTJ (ORCPT + 1 other); Fri, 2 Jun 2017 08:19:09 -0400 Received: from mx07-00252a01.pphosted.com ([62.209.51.214]:9887 "EHLO mx07-00252a01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751125AbdFBMTI (ORCPT ); Fri, 2 Jun 2017 08:19:08 -0400 Received: from pps.filterd (m0102628.ppops.net [127.0.0.1]) by mx07-00252a01.pphosted.com (8.16.0.20/8.16.0.20) with SMTP id v52CDLsa011757 for ; Fri, 2 Jun 2017 13:19:07 +0100 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.org; h=from : to : cc : subject : date : message-id : in-reply-to : references : in-reply-to : references; s=pp; bh=/HrD5TGBvQO3EsuSwBNXmc1rg0GJFoyk+pFEwnyimiA=; b=EVzHOCIoDp07ktiqcEWzwcT2leaZNPB2TVt3Fpi8D+tL5OJYvgcgUNmWbqGnEQQko3FE 6+RZm8EizS/JXhVSqMvdvQzorYe6xiiSo1NysE4ek6tVgblvfebG3eHcBANO4XUFU464 1i+kLn7xXfBdd3m+Auvyvi7pNv+BC0lNEBEUbZWZzHZ3pugrK/gV4sTZpy7JJDKN7Qhc bv1kZaA3vRszo/ZUDWhXAxEAcgLa5Tqza6ONM1ET1Qk31tn4+cWhH8gKlA9xjyDWNUeb Tahuo4rDpdmbO0UbpKbhPJ2W8J90BfKykp8P8JihgDUv1LPrS6/8EEIVaZ5ZAOOHbdi7 9w== Received: from mail-wm0-f69.google.com (mail-wm0-f69.google.com [74.125.82.69]) by mx07-00252a01.pphosted.com with ESMTP id 2apxuyawfs-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=OK) for ; Fri, 02 Jun 2017 13:19:07 +0100 Received: by mail-wm0-f69.google.com with SMTP id 10so16808578wml.4 for ; Fri, 02 Jun 2017 05:19:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi-org.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=/HrD5TGBvQO3EsuSwBNXmc1rg0GJFoyk+pFEwnyimiA=; b=QebjQsVxq0Nr4Mt+L4TYTYCl/+KWNi1e7vjeaKWZhIyjyBZ7xRkjmAaxzwR2lTopby xhQRVMX0MDCcczLyMtZOCNrdw5e5YT1QqA2tFYyj7CmhdR+CEVJFWr4TIcpkZ8SdME9o +3XeN9nnhqUF9cWaTyWYZTYV0gw0bGSlLcBt+m7FXXT9akdhAzhw5V/LXUeH4c5GHEi+ C3dykZT2FFSzyUy9dEXM808VLLcQ8z6oNvNMpxB8kzRgKFEGZ3tNPz3zwZ5RJeY2zOlL wvaGDEewWddeZyJvdK+gwTkUleZOBEXzjA7H1s18mS5pZA9HXhFIXXae7pQzAHQPPLG+ PHNQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:in-reply-to:references; bh=/HrD5TGBvQO3EsuSwBNXmc1rg0GJFoyk+pFEwnyimiA=; b=CT/35qxyqvrdjPNEzDA2hqYw37hxKp2QvV493994FLqkD1NEWZa+1botoeZGtPFWFj UsWKNMz0yxdyFrgTNozEnp/gjuhgXi5Sx+7NVBkuEK5BdixBjuWNqh0EDfOVYlcy4FSg lWC+yLiAP1fAELKqryo3pMz7jHHAN1DU+ohWIOVRtrJVbOobHHyUppwJSKq+C7me720B 1Obskj1nb8ArWUZQlEBtlpNmGNQlE3VIJ0hsV6CpcVmqLAdpIWYsN4/pablnJma1st/K HdIiWrwcOGpJjjz/Rje/aJ9zula1BwINXXyDmows5BnuzKIkmSjTqt5bCTm4fzGwikXo 4kJw== X-Gm-Message-State: AODbwcDcplRcgbr6Nx/rw11mc3Gesm2XnihHalR7ID0jEn0cThn7pNc/ Q9smYXmENP2mgt30vygN84mafEiM99tamX3KRYoeu5WcG3UdgIgNxq7FaUDolfg8sP3ISBLwHXL p61eAHuSg8JTuVA== X-Received: by 10.223.175.120 with SMTP id z111mr5689117wrc.1.1496405946164; Fri, 02 Jun 2017 05:19:06 -0700 (PDT) X-Received: by 10.223.175.120 with SMTP id z111mr5689101wrc.1.1496405945974; Fri, 02 Jun 2017 05:19:05 -0700 (PDT) Received: from localhost.localdomain ([217.33.127.173]) by smtp.googlemail.com with ESMTPSA id l190sm2706032wmb.18.2017.06.02.05.19.04 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 02 Jun 2017 05:19:05 -0700 (PDT) From: Dave Stevenson To: Mats Randgaard , Mauro Carvalho Chehab , linux-media@vger.kernel.org Cc: Dave Stevenson Subject: [PATCH 3/3] [media] tc358743: Add support for platforms without IRQ line Date: Fri, 2 Jun 2017 13:18:14 +0100 Message-Id: X-Mailer: git-send-email 2.7.4 In-Reply-To: References: In-Reply-To: References: X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-06-02_06:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_spam_notspam policy=outbound_spam score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 impostorscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1703280000 definitions=main-1706020227 Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-PMX-Version: 6.0.0.2142326, Antispam-Engine: 2.7.2.2107409, Antispam-Data: 2017.6.2.120915 X-PMX-Spam: Gauge=IIIIIIII, Probability=8%, Report=' HTML_00_01 0.05, HTML_00_10 0.05, BODY_SIZE_3000_3999 0, BODY_SIZE_5000_LESS 0, BODY_SIZE_7000_LESS 0, DKIM_SIGNATURE 0, IN_REP_TO 0, LEGITIMATE_SIGNS 0, MSG_THREAD 0, MULTIPLE_REAL_RCPTS 0, NO_URI_HTTPS 0, REFERENCES 0, __ANY_URI 0, __CC_NAME 0, __CC_NAME_DIFF_FROM_ACC 0, __CC_REAL_NAMES 0, __FROM_DOMAIN_IN_ANY_CC2 0, __FROM_DOMAIN_IN_RCPT 0, __HAS_CC_HDR 0, __HAS_FROM 0, __HAS_LIST_ID 0, __HAS_MSGID 0, __HAS_X_MAILER 0, __HAS_X_MAILING_LIST 0, __IN_REP_TO 0, __MIME_TEXT_ONLY 0, __MIME_TEXT_P 0, __MIME_TEXT_P1 0, __NO_HTML_TAG_RAW 0, __REFERENCES 0, __SANE_MSGID 0, __SUBJ_ALPHA_END 0, __TO_MALFORMED_2 0, __TO_NAME 0, __TO_NAME_DIFF_FROM_ACC 0, __TO_REAL_NAMES 0, __URI_NO_WWW 0, __URI_NS , __YOUTUBE_RCVD 0' interrupts is listed as an optional property in the DT binding, but in reality the driver didn't work without it. The existing driver relied on having the interrupt line connected to the SoC to trigger handling various events. Add the option to poll the interrupt status register via a timer if no interrupt source is defined. Signed-off-by: Dave Stevenson --- drivers/media/i2c/tc358743.c | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/drivers/media/i2c/tc358743.c b/drivers/media/i2c/tc358743.c index 2f5763d..654aac2 100644 --- a/drivers/media/i2c/tc358743.c +++ b/drivers/media/i2c/tc358743.c @@ -33,6 +33,7 @@ #include #include #include +#include #include #include #include @@ -61,6 +62,8 @@ MODULE_LICENSE("GPL"); #define I2C_MAX_XFER_SIZE (EDID_BLOCK_SIZE + 2) +#define POLL_INTERVAL_MS 1000 + static const struct v4l2_dv_timings_cap tc358743_timings_cap = { .type = V4L2_DV_BT_656_1120, /* keep this initialization for compatibility with GCC < 4.4.6 */ @@ -91,6 +94,9 @@ struct tc358743_state { struct delayed_work delayed_work_enable_hotplug; + struct timer_list timer; + struct work_struct work_i2c_poll; + /* edid */ u8 edid_blocks_written; @@ -1319,6 +1325,24 @@ static irqreturn_t tc358743_irq_handler(int irq, void *dev_id) return handled ? IRQ_HANDLED : IRQ_NONE; } +static void tc358743_irq_poll_timer(unsigned long arg) +{ + struct tc358743_state *state = (struct tc358743_state *)arg; + + schedule_work(&state->work_i2c_poll); + + mod_timer(&state->timer, jiffies + msecs_to_jiffies(POLL_INTERVAL_MS)); +} + +static void tc358743_work_i2c_poll(struct work_struct *work) +{ + struct tc358743_state *state = container_of(work, + struct tc358743_state, work_i2c_poll); + bool handled; + + tc358743_isr(&state->sd, 0, &handled); +} + static int tc358743_subscribe_event(struct v4l2_subdev *sd, struct v4l2_fh *fh, struct v4l2_event_subscription *sub) { @@ -1933,6 +1957,14 @@ static int tc358743_probe(struct i2c_client *client, "tc358743", state); if (err) goto err_work_queues; + } else { + INIT_WORK(&state->work_i2c_poll, + tc358743_work_i2c_poll); + state->timer.data = (unsigned long)state; + state->timer.function = tc358743_irq_poll_timer; + state->timer.expires = jiffies + + msecs_to_jiffies(POLL_INTERVAL_MS); + add_timer(&state->timer); } tc358743_enable_interrupts(sd, tx_5v_power_present(sd)); @@ -1948,6 +1980,8 @@ static int tc358743_probe(struct i2c_client *client, return 0; err_work_queues: + if (!state->i2c_client->irq) + flush_work(&state->work_i2c_poll); cancel_delayed_work(&state->delayed_work_enable_hotplug); mutex_destroy(&state->confctl_mutex); err_hdl: @@ -1961,6 +1995,10 @@ static int tc358743_remove(struct i2c_client *client) struct v4l2_subdev *sd = i2c_get_clientdata(client); struct tc358743_state *state = to_state(sd); + if (!state->i2c_client->irq) { + del_timer_sync(&state->timer); + flush_work(&state->work_i2c_poll); + } cancel_delayed_work(&state->delayed_work_enable_hotplug); v4l2_async_unregister_subdev(sd); v4l2_device_unregister_subdev(sd);