From patchwork Thu Jun 15 15:40:22 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dave Stevenson X-Patchwork-Id: 41909 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 1dLWsr-0007Ii-C7; Thu, 15 Jun 2017 15:40:33 +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-7) with esmtp id 1dLWso-0008UX-24; Thu, 15 Jun 2017 17:40:33 +0200 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752030AbdFOPk2 (ORCPT + 1 other); Thu, 15 Jun 2017 11:40:28 -0400 Received: from mx08-00252a01.pphosted.com ([91.207.212.211]:54739 "EHLO mx08-00252a01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751752AbdFOPk1 (ORCPT ); Thu, 15 Jun 2017 11:40:27 -0400 Received: from pps.filterd (m0102629.ppops.net [127.0.0.1]) by mx08-00252a01.pphosted.com (8.16.0.20/8.16.0.20) with SMTP id v5FFd2Sh014203 for ; Thu, 15 Jun 2017 16:40:25 +0100 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.org; h=mime-version : in-reply-to : references : from : date : message-id : subject : to : cc : content-type; s=pp; bh=6Cfe8FntIZjj0A+tXZ9jAtmO5zxs7EvKZsopqtoe9Pg=; b=Q1S+WXlKEEa5d34h7SBzdYxsIL83/MtyaVkRJFwKzhH30ZeQzh6wHTVBzUdISCpjiXas OwFw1C6SGyUBmhYnrKCS236/FfEkKaxvTyOV0RaXOa0YXuI7xAEDkM0CDqVmolCVn9nf vP+9vu/KdXvgJIASldTgOLAFd8OrwstF+aNZ8dpBbeQaT6MpuHB2qODzqhbg5SI8pB3l XhUn4O/gz2EQr9wR22T6LAKZmL0SBsH7U3j4BcUpFVGJg1Z4A0q4/e21varOaEdDoDUY Q8kH4mZXKV8UMiMhlbLGFp/dv4K8rkWYZ9RzXXj+pnVB+NxImd+taZyvhly9TRDNmZMu HQ== Received: from mail-pg0-f69.google.com (mail-pg0-f69.google.com [74.125.83.69]) by mx08-00252a01.pphosted.com with ESMTP id 2b058etpwg-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=OK) for ; Thu, 15 Jun 2017 16:40:25 +0100 Received: by mail-pg0-f69.google.com with SMTP id e187so15757904pgc.7 for ; Thu, 15 Jun 2017 08:40:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi-org.20150623.gappssmtp.com; s=20150623; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=6Cfe8FntIZjj0A+tXZ9jAtmO5zxs7EvKZsopqtoe9Pg=; b=1Vb2ypbggEYqi/ZaKzJtTZeyV8XyNEtcfXQSzt4Mrn8exPcrmz4B4l3NgEINeZFrqp tCMv5B1+X2m+x+hbdlUlxBJNzN+uOqqYeglwVJI51dIWx1Soy8CvFv34jnQNuiTPlGW/ GjSasfGqCE68oa1W55W5+5QDVoeTEGy+ybZHCpC7wWnQliB47oScnne1Yr+N8YWRlEWC /pfi9VrdPm1drA4O6glr4tL5n8yIKR1oHtaSct06LgYYUSSNWy6BUiHepyn2n8u37x8U ubCElgul8QW9RJv5Dq2g+7RrpXRG4axfHoxFtIrHIIwNLsoLCde6Img8vUcImSisA90e 9gNw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=6Cfe8FntIZjj0A+tXZ9jAtmO5zxs7EvKZsopqtoe9Pg=; b=oRpnve+0MtjnqObVA6IJeek8laTrUbXCTXjGlzwN49aFnT/g3gwmIPOsQClt368Td1 DlMDqyLhmZy4UbVwpipF5sJt3C7+Yhl+/OIbpYbmzV6PHJwC3zgN6MwJO+bVTd18exNn g7MkZh+jc6j+zHnhpDcUNFT0KHZ4kHKQh1TXm0OUc4IwYfjC8PWiSbE745pMXypWQFiW pgEYjnu+THeuigEuBIMVYOINz9k73Lyn+8IJ1ugVm7STs2ZfTWHINL4l+PvpgM2PJNy4 oTGXWn7q+ULUu1riiVm+1EN2zC3d84YnV3Do849hdKepP1xVOOce5QKiazZurIhlzhuN hiGA== X-Gm-Message-State: AKS2vOzaZPQx1x26tNM68riet9l+7VwWVcX067sHjKzhkRkiS/4fZu1W SzvM2ktxbOP+kGdT3zXCaH9ojK9gqO+X+MQDu8E5ot96nNBCAUQ5lFc8H64OT/EzuCkO6mPAIzB f707atwit4ugaC40Jxtcod9oeZcQyQg== X-Received: by 10.84.245.2 with SMTP id i2mr7154633pll.284.1497541222996; Thu, 15 Jun 2017 08:40:22 -0700 (PDT) X-Received: by 10.84.245.2 with SMTP id i2mr7154612pll.284.1497541222752; Thu, 15 Jun 2017 08:40:22 -0700 (PDT) MIME-Version: 1.0 Received: by 10.100.184.9 with HTTP; Thu, 15 Jun 2017 08:40:22 -0700 (PDT) In-Reply-To: <2de5b0c1-2408-2a12-8c4c-fa91658e0c0b@i2se.com> References: <2de5b0c1-2408-2a12-8c4c-fa91658e0c0b@i2se.com> From: Dave Stevenson Date: Thu, 15 Jun 2017 16:40:22 +0100 Message-ID: Subject: Re: [RFC 2/2] [media] bcm2835-unicam: Driver for CCP2/CSI2 camera interface To: Stefan Wahren Cc: Hans Verkuil , Mauro Carvalho Chehab , linux-rpi-kernel@lists.infradead.org, linux-media@vger.kernel.org X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-06-15_08:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_spam_notspam policy=outbound_spam score=0 priorityscore=1501 malwarescore=0 suspectscore=1 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-1706150270 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.15.153016 X-PMX-Spam: Gauge=IIIIIIII, Probability=8%, Report=' MULTIPLE_RCPTS 0.1, HTML_00_01 0.05, HTML_00_10 0.05, CT_TEXT_PLAIN_UTF8_CAPS 0, DKIM_SIGNATURE 0, IN_REP_TO 0, LEGITIMATE_SIGNS 0, MSG_THREAD 0, NO_URI_HTTPS 0, REFERENCES 0, WEBMAIL_SOURCE 0, __ANY_URI 0, __BOUNCE_CHALLENGE_SUBJ 0, __BOUNCE_NDR_SUBJ_EXEMPT 0, __CC_NAME 0, __CC_NAME_DIFF_FROM_ACC 0, __CC_REAL_NAMES 0, __CT 0, __CT_TEXT_PLAIN 0, __FORWARDED_MSG 0, __FROM_DOMAIN_IN_ANY_CC1 0, __FROM_DOMAIN_IN_RCPT 0, __HAS_CC_HDR 0, __HAS_FROM 0, __HAS_LIST_ID 0, __HAS_MSGID 0, __HAS_X_MAILING_LIST 0, __IN_REP_TO 0, __MIME_TEXT_ONLY 0, __MIME_TEXT_P 0, __MIME_TEXT_P1 0, __MIME_VERSION 0, __MULTIPLE_RCPTS_CC_X2 0, __NO_HTML_TAG_RAW 0, __PHISH_SPEAR_HTTP_RECEIVED 0, __PHISH_SPEAR_STRUCTURE_1 0, __REFERENCES 0, __SANE_MSGID 0, __SUBJ_ALPHA_END 0, __SUBJ_ALPHA_NEGATE 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' Hi Stefan. On 15 June 2017 at 15:49, Stefan Wahren wrote: > Hi Dave, > > Am 15.06.2017 um 15:38 schrieb Dave Stevenson: >> Hi Hans. >> >> "On 15 June 2017 at 08:12, Hans Verkuil wrote: >>> Hi Dave, >>> >>> Here is a quick review of this driver. Once a v2 is posted I'll do a more >>> thorough >>> check. >> Thank you. I wasn't expecting such a quick response. >> >>> On 06/14/2017 05:15 PM, Dave Stevenson wrote: >>>> ... >>>> >>>> + >>>> +struct bayer_fmt { >>>> + u32 fourcc; >>>> + u8 depth; >>>> +}; >>>> + >>>> +const struct bayer_fmt all_bayer_bggr[] = { >>>> + {V4L2_PIX_FMT_SBGGR8, 8}, >>>> + {V4L2_PIX_FMT_SBGGR10P, 10}, >>>> + {V4L2_PIX_FMT_SBGGR12, 12}, >>>> + {V4L2_PIX_FMT_SBGGR16, 16}, >>>> + {0, 0} >>>> +}; >>>> + >>>> +const struct bayer_fmt all_bayer_rggb[] = { >>>> + {V4L2_PIX_FMT_SRGGB8, 8}, >>>> + {V4L2_PIX_FMT_SRGGB10P, 10}, >>>> + {V4L2_PIX_FMT_SRGGB12, 12}, >>>> + /* V4L2_PIX_FMT_SRGGB16, 16},*/ >>> >>> Why is this commented out? Either uncomment, add a proper comment explaining >>> why >>> or remove it. >> I was developing this against the Pi specific tree, and that is still >> on 4.9 which didn't have several of the 16 bit Bayer formats. I see >> that Sakari has added them (thank you Sakari), so I can uncomment >> them. > > does this series work with Linux Mainline (incl. bcm283x dts files)? > > In case not, please tell what is missing? I switched about a week or so back onto mainline, partly to pick up and use the recent fwnode parsing changes within V4L2. This driver is working with Mainline and bcm283x.dts once the relevant DT sections are added. The DT changes aren't in a state to post as a patch set as yet. The main stumbiling block is that the camera I2C is BSC0 but typically on GPIOs 28&29 instead of 0&1 (44&45 on Pi3). Swapping to 28&29 would be a significant change in behaviour so wouldn't be acceptable. If it can be knocked in to shape then the i2c-mux-pinctrl driver appears to do what is required to make 0&1 and 28&29 appear as 2 independent I2C buses, but I haven't had the time as yet to finesse that. It needs some care as 44&45 (needed for the camera on Pi3) are used for the SMSC9514 clock and audio on Pi2, so the configuration needs to be sorted per platform. (switching off the 9514 clock results in no ethernet or USB, so generally means time for a swift reboot - been there, done that). The DT diffs I have for running on a Pi2 are: diff --git a/arch/arm/boot/dts/bcm2835-rpi.dtsi b/arch/arm/boot/dts/bcm2835-rpi.dtsi index a7b5ce1..1f24219 100644 --- a/arch/arm/boot/dts/bcm2835-rpi.dtsi +++ b/arch/arm/boot/dts/bcm2835-rpi.dtsi @@ -46,7 +46,7 @@ &i2c0 { pinctrl-names = "default"; - pinctrl-0 = <&i2c0_gpio0>; + pinctrl-0 = <&i2c0_gpio28>; status = "okay"; clock-frequency = <100000>; }; @@ -106,3 +106,11 @@ &dsi1 { power-domains = <&power RPI_POWER_DOMAIN_DSI1>; }; + +&csi0 { + power-domains = <&power RPI_POWER_DOMAIN_UNICAM0>; +}; + +&csi1 { + power-domains = <&power RPI_POWER_DOMAIN_UNICAM1>; +}; diff --git a/arch/arm/boot/dts/bcm283x.dtsi b/arch/arm/boot/dts/bcm283x.dtsi index 561f27d..4c575e4 100644 --- a/arch/arm/boot/dts/bcm283x.dtsi +++ b/arch/arm/boot/dts/bcm283x.dtsi @@ -512,6 +512,34 @@ status = "disabled"; }; + csi0: csi0@7e800000 { + compatible = "brcm,bcm2835-unicam"; + reg = <0x7e800000 0x800>, + <0x7e802000 0x4>; + interrupts = <2 6>; + clocks = <&clocks BCM2835_CLOCK_CAM0>; + clock-names = "lp_clock"; + #address-cells = <1>; + #size-cells = <0>; + #clock-cells = <1>; + + status = "disabled"; + }; + + csi1: csi1@7e801000 { + compatible = "brcm,bcm2835-unicam"; + reg = <0x7e801000 0x800>, + <0x7e802004 0x4>; + interrupts = <2 7>; + clocks = <&clocks BCM2835_CLOCK_CAM1>; + clock-names = "lp_clock"; + #address-cells = <1>; + #size-cells = <0>; + #clock-cells = <1>; + + status = "disabled"; + }; + i2c1: i2c@7e804000 { compatible = "brcm,bcm2835-i2c"; reg = <0x7e804000 0x1000>; and then an overlay to add the TC358743 diff --git a/arch/arm/boot/dts/overlays/tc358743-overlay.dts b/arch/arm/boot/dts/overlays/tc358743-overlay.dts new file mode 100644 index 0000000..b205ca1 --- /dev/null +++ b/arch/arm/boot/dts/overlays/tc358743-overlay.dts @@ -0,0 +1,72 @@ +// Definitions for Toshiba TC358743 HDMI to CSI2 bridge on VC I2C bus +/dts-v1/; +/plugin/; + +/{ + compatible = "brcm,bcm2708"; + + fragment@0 { + target = <&i2c_vc>; + __overlay__ { + #address-cells = <1>; + #size-cells = <0>; + status = "okay"; + + tc358743@0f { + compatible = "toshiba,tc358743"; + reg = <0x0f>; + status = "okay"; + + clocks = <&tc358743_clk>; + clock-names = "refclk"; + + tc358743_clk: bridge-clk { + compatible = "fixed-clock"; + #clock-cells = <0>; + clock-frequency = <27000000>; + }; + + port { + tc358743: endpoint { + remote-endpoint = <&csi1>; + clock-lanes = <0>; + data-lanes = <1 2>; + clock-noncontinuous; + link-frequencies = /bits/ 64 <297000000>; + }; + }; + }; + }; + }; + + fragment@1 { + target = <&csi1>; + __overlay__ { + #address-cells = <1>; + #size-cells = <0>; + status = "okay"; + + port { + #address-cells = <1>; + #size-cells = <0>; + + endpoint { + remote-endpoint = <&tc358743>; + }; + }; + }; + }; +}; Apologies for the formatting - it'll obviously be cleaned up before submitting as a patch. Dave