From patchwork Sun Dec 1 21:06:55 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Frank_Sch=C3=A4fer?= X-Patchwork-Id: 3262661 Return-Path: X-Original-To: patchwork-linux-media@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 3D8C29F387 for ; Sun, 1 Dec 2013 21:06:48 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 5C32F203AA for ; Sun, 1 Dec 2013 21:06:47 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 26589203DA for ; Sun, 1 Dec 2013 21:06:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752303Ab3LAVGo (ORCPT ); Sun, 1 Dec 2013 16:06:44 -0500 Received: from mail-ea0-f174.google.com ([209.85.215.174]:35834 "EHLO mail-ea0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751417Ab3LAVGW (ORCPT ); Sun, 1 Dec 2013 16:06:22 -0500 Received: by mail-ea0-f174.google.com with SMTP id b10so8210595eae.5 for ; Sun, 01 Dec 2013 13:06:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-type:content-transfer-encoding; bh=c1HhlcIVuzpYtJhOuMK7lMJ+bRF3/MbaTx1ORyRmXg8=; b=S6Z6b8CAM8q/AOcB1b8o8mfh0FLpm8hx+pSs6oZz1ecfNrwPf+6WvGL+ggHWMkyp0c Gszn4ixK5iPQNvfMYhBL0dGDW2bmwZIV766gffya39er2XMsCsxzr9JpfyuFmpwECgDL QW9onEH8xOMcTZAGbcsSBpshZW9+5pfbLFyVTts6a+PZCSi6bYKWVSM6v2JOnG+1ODXK Uyif9578T/2NKWvPMBqEqnlTuxPCZULyNh5tOdGpr4LCO0K5WIsOtcBr/qJkZXqt66yo XFji7xrilEE8BY0o3LPhQJ2/MBI92/a3dZBE3ZZ5u8q4nd7EuJcHKJg5BWqzYaz9rxz8 Pdsg== X-Received: by 10.14.119.1 with SMTP id m1mr25993eeh.39.1385931980939; Sun, 01 Dec 2013 13:06:20 -0800 (PST) Received: from Athlon64X2-5000.site (ip-178-203-183-60.unitymediagroup.de. [178.203.183.60]) by mx.google.com with ESMTPSA id b42sm63981851eem.9.2013.12.01.13.06.20 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 01 Dec 2013 13:06:20 -0800 (PST) From: =?UTF-8?q?Frank=20Sch=C3=A4fer?= To: m.chehab@samsung.com Cc: linux-media@vger.kernel.org, =?UTF-8?q?Frank=20Sch=C3=A4fer?= Subject: [PATCH 5/7] em28xx: prepare for supporting multiple LEDs Date: Sun, 1 Dec 2013 22:06:55 +0100 Message-Id: <1385932017-2276-6-git-send-email-fschaefer.oss@googlemail.com> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1385932017-2276-1-git-send-email-fschaefer.oss@googlemail.com> References: <1385932017-2276-1-git-send-email-fschaefer.oss@googlemail.com> MIME-Version: 1.0 Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Introduce a LED role and store all LEDs in an array. Also provide a helper function to retrieve a specific LED. Signed-off-by: Frank Schäfer --- drivers/media/usb/em28xx/em28xx-core.c | 31 ++++++++++++++++++++++++------- drivers/media/usb/em28xx/em28xx.h | 10 +++++++++- 2 Dateien geändert, 33 Zeilen hinzugefügt(+), 8 Zeilen entfernt(-) diff --git a/drivers/media/usb/em28xx/em28xx-core.c b/drivers/media/usb/em28xx/em28xx-core.c index 31d6ab2..4a8179a 100644 --- a/drivers/media/usb/em28xx/em28xx-core.c +++ b/drivers/media/usb/em28xx/em28xx-core.c @@ -600,6 +600,22 @@ int em28xx_colorlevels_set_default(struct em28xx *dev) return em28xx_write_reg(dev, EM28XX_R1A_BOFFSET, 0x00); } +const struct em28xx_led *em28xx_find_led(struct em28xx *dev, + enum em28xx_led_role role) +{ + if (dev->board.leds) { + u8 k = 0; + while (dev->board.leds[k].role >= 0 && + dev->board.leds[k].role < EM28XX_NUM_LED_ROLES) { + if (dev->board.leds[k].role == role) + return &dev->board.leds[k]; + k++; + } + } + return NULL; +} +EXPORT_SYMBOL_GPL(em28xx_find_led); + int em28xx_capture_start(struct em28xx *dev, int start) { int rc; @@ -645,13 +661,14 @@ int em28xx_capture_start(struct em28xx *dev, int start) return rc; /* Switch (explicitly controlled) analog capturing LED on/off */ - if ((dev->mode == EM28XX_ANALOG_MODE) - && dev->board.analog_capturing_led) { - struct em28xx_led *led = dev->board.analog_capturing_led; - em28xx_write_reg_bits(dev, led->gpio_reg, - (!start ^ led->inverted) ? - ~led->gpio_mask : led->gpio_mask, - led->gpio_mask); + if (dev->mode == EM28XX_ANALOG_MODE) { + const struct em28xx_led *led; + led = em28xx_find_led(dev, EM28XX_LED_ANALOG_CAPTURING); + if (led) + em28xx_write_reg_bits(dev, led->gpio_reg, + (!start ^ led->inverted) ? + ~led->gpio_mask : led->gpio_mask, + led->gpio_mask); } return rc; diff --git a/drivers/media/usb/em28xx/em28xx.h b/drivers/media/usb/em28xx/em28xx.h index df828c6..f60f236 100644 --- a/drivers/media/usb/em28xx/em28xx.h +++ b/drivers/media/usb/em28xx/em28xx.h @@ -377,7 +377,13 @@ enum em28xx_adecoder { EM28XX_TVAUDIO, }; +enum em28xx_led_role { + EM28XX_LED_ANALOG_CAPTURING = 0, + EM28XX_NUM_LED_ROLES, /* must be the last */ +}; + struct em28xx_led { + enum em28xx_led_role role; u8 gpio_reg; u8 gpio_mask; bool inverted; @@ -433,7 +439,7 @@ struct em28xx_board { char *ir_codes; /* LEDs that need to be controlled explicitly */ - struct em28xx_led *analog_capturing_led; + struct em28xx_led *leds; /* Buttons */ struct em28xx_button *buttons; @@ -711,6 +717,8 @@ int em28xx_audio_analog_set(struct em28xx *dev); int em28xx_audio_setup(struct em28xx *dev); int em28xx_colorlevels_set_default(struct em28xx *dev); +const struct em28xx_led *em28xx_find_led(struct em28xx *dev, + enum em28xx_led_role role); int em28xx_capture_start(struct em28xx *dev, int start); int em28xx_vbi_supported(struct em28xx *dev); int em28xx_set_outfmt(struct em28xx *dev);