From patchwork Sun Jul 8 02:05:34 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hyun Kwon X-Patchwork-Id: 10513001 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 6D0BD600CA for ; Sun, 8 Jul 2018 02:07:51 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 59D6E289CC for ; Sun, 8 Jul 2018 02:07:51 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4BFB4289D2; Sun, 8 Jul 2018 02:07:51 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAD_ENC_HEADER,BAYES_00, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 85422289CC for ; Sun, 8 Jul 2018 02:07:49 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id C2C7C6E374; Sun, 8 Jul 2018 02:07:39 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from NAM02-CY1-obe.outbound.protection.outlook.com (mail-cys01nam02on0051.outbound.protection.outlook.com [104.47.37.51]) by gabe.freedesktop.org (Postfix) with ESMTPS id C0F1F6E36E for ; Sun, 8 Jul 2018 02:07:36 +0000 (UTC) Received: from MWHPR02CA0024.namprd02.prod.outlook.com (2603:10b6:300:4b::34) by BYAPR02MB4454.namprd02.prod.outlook.com (2603:10b6:a03:57::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.930.20; Sun, 8 Jul 2018 02:07:31 +0000 Received: from CY1NAM02FT031.eop-nam02.prod.protection.outlook.com (2a01:111:f400:7e45::208) by MWHPR02CA0024.outlook.office365.com (2603:10b6:300:4b::34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.930.19 via Frontend Transport; Sun, 8 Jul 2018 02:07:30 +0000 Received-SPF: Pass (protection.outlook.com: domain of xilinx.com designates 149.199.60.100 as permitted sender) receiver=protection.outlook.com; client-ip=149.199.60.100; helo=xsj-pvapsmtpgw02; Received: from xsj-pvapsmtpgw02 (149.199.60.100) by CY1NAM02FT031.mail.protection.outlook.com (10.152.75.180) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.20.906.15 via Frontend Transport; Sun, 8 Jul 2018 02:07:30 +0000 Received: from unknown-38-66.xilinx.com ([149.199.38.66]:35389 helo=xsj-pvapsmtp01) by xsj-pvapsmtpgw02 with esmtp (Exim 4.63) (envelope-from ) id 1fbz6n-0004jX-Rx; Sat, 07 Jul 2018 19:07:29 -0700 Received: from [127.0.0.1] (helo=xsj-smtp-dlp2.xlnx.xilinx.com) by xsj-pvapsmtp01 with esmtp (Exim 4.63) (envelope-from ) id 1fbz6i-0003VV-Na; Sat, 07 Jul 2018 19:07:24 -0700 Received: from xsj-pvapsmtp01 (mailman.xilinx.com [149.199.38.66]) by xsj-smtp-dlp2.xlnx.xilinx.com (8.13.8/8.13.1) with ESMTP id w6827NJJ009460; Sat, 7 Jul 2018 19:07:24 -0700 Received: from [172.19.2.244] (helo=xsjhyunkubuntu) by xsj-pvapsmtp01 with esmtp (Exim 4.63) (envelope-from ) id 1fbz6h-0003VE-PW; Sat, 07 Jul 2018 19:07:23 -0700 Received: by xsjhyunkubuntu (Postfix, from userid 13638) id 5D4B62C73CE; Sat, 7 Jul 2018 19:05:40 -0700 (PDT) From: Hyun Kwon To: , , Laurent Pinchart Subject: [PATCH v8 1/5] drm: xlnx: Xilinx DRM KMS module Date: Sat, 7 Jul 2018 19:05:34 -0700 Message-ID: <1531015538-32268-2-git-send-email-hyun.kwon@xilinx.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1531015538-32268-1-git-send-email-hyun.kwon@xilinx.com> References: <1531015538-32268-1-git-send-email-hyun.kwon@xilinx.com> X-RCIS-Action: ALLOW X-TM-AS-Product-Ver: IMSS-7.1.0.1224-8.2.0.1013-23620.005 X-TM-AS-User-Approved-Sender: Yes;Yes X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-HT: Tenant X-Forefront-Antispam-Report: CIP:149.199.60.100; IPV:NLI; CTRY:US; EFV:NLI; SFV:NSPM; SFS:(10009020)(39860400002)(396003)(376002)(346002)(136003)(2980300002)(438002)(55885003)(189003)(199004)(103686004)(63266004)(6266002)(16586007)(316002)(47776003)(54906003)(106466001)(4326008)(107886003)(90966002)(186003)(110136005)(42186006)(6666003)(5660300001)(53946003)(26005)(478600001)(446003)(2616005)(5024004)(486006)(44832011)(106002)(356003)(305945005)(14444005)(8936002)(476003)(50226002)(81166006)(8676002)(81156014)(48376002)(336012)(36756003)(126002)(11346002)(76176011)(52956003)(50466002)(2906002)(426003)(51416003)(107986001)(5001870100001)(217873001)(2101003); DIR:OUT; SFP:1101; SCL:1; SRVR:BYAPR02MB4454; H:xsj-pvapsmtpgw02; FPR:; SPF:Pass; LANG:en; PTR:unknown-60-100.xilinx.com,xapps1.xilinx.com; MX:1; A:1; X-Microsoft-Exchange-Diagnostics: 1; CY1NAM02FT031; 1:PsjWz28CmnmQqsI5RuTt2fpLLFZSj95TBKBzopIcoXolQArispd7wtlrB8au2+fkhFmiTymEFJPxxb2S6z2Zmklrm9Xi5L2/AAyuLHXxnIRSCXp6aJIXs1vZV4Leev1B MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 698f48be-c98e-438a-b901-08d5e4778fd1 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652040)(8989117)(5600053)(711020)(4608076)(4534165)(4627221)(201703031133081)(201702281549075)(8990107)(2017052603328)(7153060); SRVR:BYAPR02MB4454; X-Microsoft-Exchange-Diagnostics: 1; BYAPR02MB4454; 3:fWqMKY0n7IYzF6d+PuotsL31J6GXl709HHZir14Lc7nFH8DeL4CmtQ4qBm0mST0QMxsoLN7X2Y+ZyM3573t97HaQ8MG9K8XD7gfCxt7P/PrzFiUdC3tVJSiNe5ZgmjN7BOZey+3V/E0uYItsO94cpoV4Nv6DwiquoEQNJYCZ4zNNXUsVK0/jLPjsJXJayIaOqakb+YW7N2aoaNHxSm+1yAcm745wFCB3KLBGFTSk9rjY2YslRoWmLDg1G7i1FHw3SQObSoQevyj5f5lei+l6knCXdn1gI1FiTiOejnFrEPwq95qxJSuDqvcBT1RV2Z+ulGIGoSNn/xqaXEWDZ3MDVbArd7GccpgoVQN6r8Pnn9Q=; 25:+AT78Fs6NhTOr4kWUxftyYm7hvljWdPQXwvUbPvDDf376sj2ov+k3Ot6FD1+8ga6TWbP98yVyiyM18riNgwKwPqKt+aPNDzqT55dAVbz8OcIowL+o7I+GRCo1Q98FhfmaBZ/lCCCM6+B8+Pu6FAwQu/wKFAwKPSLhITLMRvKBT5mMblp2HvXSw9JME9eauT26B1W+1+dQUS7GqTJLv/m6DiaagJQ92FwM1TCJ+Ozqs3rKA4uFSM4O0JY0BTsaPh2YtOIk0FYWwqcedbof1rfNjfIW+RlqalGsl7XYSYiLcNtVGKATKuI/unXTvEZdtFcSyk1xduY5EJMCWqqMKPo4w== X-MS-TrafficTypeDiagnostic: BYAPR02MB4454: X-Microsoft-Exchange-Diagnostics: 1; BYAPR02MB4454; 31:WsRjuUYlz4iKc59KbDIO0eO+wu9jGAEKroLgoFBGMkMgeHCM1+U4BW/NOEhoXqZrciQpENsXklHHaKHQl99rf2OEDXejldDkl4OkpYOqxoyynxXOdOiQsAbwYXqqmkD5OKA7JLs5kh8F+2dwBrftdU5VaRDUJkzxCuiwbKJZj1UQz64zb/RQLbYdSg1fnnPn1FnZChBYSILxaW3gvXdDTTo7Ql6IDzKREvl3sZKuh9Q=; 20:wV8rhS879BkKMnymDR1SBGbgDJabM8giqVyfs/kAgdxrtkwPfMkF///XWa2LCpRAii45uw6C0OXGdnrI08ARZBwOxEJeFfPxSgVz1J4ADdFgjMDjhLI2x/agA/nsuXFTmejRXW/oVY3hlwa0q6P9qbdeP4WFwVrA2uMb+HtVFVaxExK+CMbf0XHK/3mdnv/yHsPRRZUJ3uv9lry/0xqKteXgXVv3pw3Nt8bngKQYLGs3dAtGXKqhtJ73A1FY22ACAplYjw8Hhd5sqOVF64D0rvZxWM34oeEz8FzC1dxihRBXFjhEcxqykmgFF4XVhFkzPUffLL05sOC+8MhByfoGC1KuLfEZt5/I1lwMemMDhdIDvSf+R2FTL3a6sQvzDUtIY9f3X642sU826j7Ngwwuzv6B77KOTVwZuIC3G4mB0dDXisqgZwKl/sHPXzs1Xp7b92RbfVBNuZ1Bq1iTK3vdXX9vMD5NzWWRd7TCrrfiEBeQ6PckuSdH1HLNmXkL7mRn X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(35073007944872)(788757137089)(192813158149592)(217544274631240); X-MS-Exchange-SenderADCheck: 1 X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(5005006)(8121501046)(93006095)(93004095)(10201501046)(3231311)(944501410)(52105095)(3002001)(6055026)(149027)(150027)(6041310)(20161123562045)(20161123558120)(20161123560045)(20161123564045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(6072148)(201708071742011)(7699016); SRVR:BYAPR02MB4454; BCL:0; PCL:0; RULEID:; SRVR:BYAPR02MB4454; X-Microsoft-Exchange-Diagnostics: 1; BYAPR02MB4454; 4:9AR/z+HutWKtt/EbrgGh9odyPMXmi71Eh+BrCJH7rh0+AgCy3oUyn7vu4IdarTN+4rKAMMWNNnpsHBe5wiipBw0JYJ4fFDWu4PSG0gYFgFQgP9rt3IYuZe2cwxV6mrXO1WZ0+VVoGcpftcpwmzh/X1bWQg/Vqc8SsCJ0blOHAKgvRDOEFXF66WFwyPlt+iFnuiCZfrDJ63JDlMcwjMBmORLs2EKri2MJAO/mW2qKZtzYSAnF4gzK+/e+yIcKwoDudOMSyiTs+SUTtbSUmNft7iaPsd60BcBc8P7AAukOWFaSa7ScThmZJW9nPAuFVJ+e3emArUuCQ1bZ3Ue4HlqpNAJx0yRuErqvua9gPvXrodaj+DVoKrC4FxF9Vt4FpTHEFLGvVs6aI6+srBPCitDdkPEOx1pQ7vuOCQYc2RNSmps= X-Forefront-PRVS: 0727122FC6 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; BYAPR02MB4454; 23:865AuetHzdPIVWYRRvjuHu2meWOPmGmSy25Hzskte?= =?us-ascii?Q?SrI6TeK+fIQP8YWZuUmgWwW7bYx4I3xG9w4tdhHcFhJjM03IN5rVHEOd1S4n?= =?us-ascii?Q?BWw8zQ4NgWuhEVnkpPW2CHVXvaPjKlADNY2TNDGEHJ3lD1nDknjHQOgyBJNm?= =?us-ascii?Q?9wFh4G/e9agiTSY29vg/mhYCCNYXqGTCMilKNG/uHsy9q2ZCmb2Bme88GZDq?= =?us-ascii?Q?y5RQtIKnnZSeBvjEpJ9eVD5kluxnSUCKXlJnU/WnxU3pS+yNEQCvvGVKq09a?= =?us-ascii?Q?9fpj2EV/85X/oX2GHot8w2EEfTFD4Aeq20gh3VaMLl8R7ntTwNcbkUcFIUth?= =?us-ascii?Q?mtbgQwQseGK/DUh+jbtiBQs2TeAdrHCEtDnmwjuqvR2BEnYQaTb8smf+dBCo?= =?us-ascii?Q?Fm97FWwevj/5H3M1vosooTww21DEQa5H7b15gXU8GMieq0G2C064pO4JzhvW?= =?us-ascii?Q?TeVUOD9ERIE7qjTAQGxE++1OTFlHFnBovrBLEM1516adiaf66dL95APcwwi/?= =?us-ascii?Q?DMFEHjkpoIDMORCfU87lFMuqsmMjo6xon9dOi8rSHIpAZICFYXHW/1ambqWw?= =?us-ascii?Q?Fx/Xdofu1/vF3z9LUKS2ftSWZ2Tj7SCtMg86wmmed7SfCpdEztJcF60fHxLO?= =?us-ascii?Q?MUFXpTqTfeUGKXW7pkte70pPaBXvxMtwoThbr5zPl28QqgxZe35CxBWp0LhF?= =?us-ascii?Q?poRnn0CUhpnaCa21dLKkiUCyb3k1rCqnKm1ERJPdT5RM6Tk9QUt9yPIBLvLs?= =?us-ascii?Q?CsQ2qTkEo4cm669fNTn5f1GQ/Fjusa6hCcWFiJ3mJ+e15w48jzdpK4BaA2xL?= =?us-ascii?Q?CjjvEjucYrna8onwGTo6v4EBBCu2AAb3X/DVW5ln6EZt3s6wCg4ccbqbtdCR?= =?us-ascii?Q?6+cgBkhIXa34TbsVD1kmb1IHVO5Zl4kwjSyODJTPCZcJtUzz5IQ/Ox24GA7K?= =?us-ascii?Q?C3gMbOT07F6k33PgUDD5rsIpaNGmNUPxhYHUxliJFz4GHaqHvYAyJrKiH7b9?= =?us-ascii?Q?AMhglh9YUXo6A3rfbh9g91kPqviEHKIIZtH3i9eXf3r/fo29m6dvFlJwnKKP?= =?us-ascii?Q?KHd9IeNqK6lZKKsF36UGaW2wvz/CaeBTF6xTPmmYlX7mHHNvEQaiIAQOJOEx?= =?us-ascii?Q?O9w+5SYf4D+yyByzjxQ04IUch4Owb7Qj7x74J9Cc7y+RtPkJdvRSmPZ/CVPM?= =?us-ascii?Q?8nJaXI7FNOzjYlEHOGqGmVkQGm6Rrp6IeKVAqusDDFrkEAJQqG5woj/cqhq5?= =?us-ascii?Q?onQACpHdGWSPtctGC0OHzUbz6PjAsml7w9jElupd+HoYkpnSk4CUmHRK/fPo?= =?us-ascii?Q?l7HpV/6cIIAW4YtXGHrypg=3D?= X-Microsoft-Antispam-Message-Info: I4duCupCakeWg672cGqrKr7W7RDTOZtlFqKAeEmjJbL73sxTpMLgdCJre0/7Vv+RNkRarsp/7Ye2SKhQV1SZ9CdKjTwXjlT4mdMHZ2qkJ5TltwIYZ1ESTkHs0T4tZH/RySroo51Ozxlt2Nx5V0+LyNZBqzua3A03R/M9DcqTD+tl4AILyaEYTcCWwjUBHYORzn4HkVyNRDi3pCgkBhJee0X+XIkh3fy+dQvyXacKBKj8JMLzbPeHoanIDDAcyJXcz3FfSN+FUPfEBteIbp+Q0RlxPaYoDoFisSt4IEyk3ZJjs7frLVt67ot7LyoalB+JYwfaOD6T13lRXY1vqXcpb9M2BM67Ynlws3uaugeMWxM= X-Microsoft-Exchange-Diagnostics: 1; BYAPR02MB4454; 6:QSRJFZMt1bXFFr+nsZ/KKovn9F9/SaiVtnJVPsBABfJyUbQvV10Znh7QjRgo5st+MPWMjX/09vxFgoyMRQHXxvR7SB509BsqrEQ5cPCWYB7DGeA6Kj9YU+n49Sz+PglqlJ+eKc3aDtH/cUvbAq+tvrl1Kzd3KGzJj8JmHAAV4anfCFvi7G+hlxzPhLanp5rzMZwlSEmnSrjIywTBxcDSU+0Wbugmt3saEUu4D4h0Z9QAtcP7PTyKFEBMlJhHG7vuhiIFWX3ZxlJeqnbmyHVqGmBMI1HFmFfOWnPNH8EGRwTWrEZfQwGOg9pM+hKKajwydGpIShmnTP3ht46J4KcAu/7LFBR3/1/jiBNSXej2Yz+2r8nSlxt8rH/XmOtX2reRUfIMtU1o/uzc3VE90T7Ojlw2CimZaAymls2zeyq3GFy+ALAXmUQDj51sLFjhyFhu0vtDVW4NrZ4LmNpI5NRGPw==; 5:efz3HENgA8bapIROM23XciPXc6psS3hclTy8Q0wVaTFwU3xIu8R4ojVVOyinGsCXsjBrl5Ie14S1ATahYqG2W/t42RiPEeNGDGINlBKOq/rKEkzgRP6A7f1tIE/U+9F34s46XswKb2Y5gDJoSi2grjnz8ay/24e6mh9Uv//ujIc=; 24:MEIPSE/IXUJpzc9zyzdAZgiqLUYi3Zes55O6I9NuR0YUnrw+Gd30tBYghgjop7QtsK/74IPE8BoPcHyhIL06LqbibqrNoWduVS69BLbPKZ0= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; BYAPR02MB4454; 7:5V7MOOOIKcGoLEnmqBylz8subV4M5pPRWTVpFHL5+eYkOxBSJcMUqDWWJ7V0w0vMFrX+6DPu2oIBhLJNkBn1BkqxTmqVZqDvba5sI2al4mWum/1+Py38q+nuVdDgukmxlerRvSVMbIRt0r1Cam5jy4YVLPfSLjX8gCYs5ZeV7o9d3BJkOebG1Zwa2MY/Y0WvvokZA4+QhDkbGRlTo68WfqAmPQlIAkANZTEwJugg7GHMPuSBZMCK90y5D7tY8kYY X-OriginatorOrg: xilinx.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Jul 2018 02:07:30.3389 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 698f48be-c98e-438a-b901-08d5e4778fd1 X-MS-Exchange-CrossTenant-Id: 657af505-d5df-48d0-8300-c31994686c5c X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=657af505-d5df-48d0-8300-c31994686c5c; Ip=[149.199.60.100]; Helo=[xsj-pvapsmtpgw02] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR02MB4454 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Daniel Vetter , Rob Herring , Michal Simek , Hyun Kwon Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP Xilinx has various platforms for display, where users can create using multiple IPs in the programmable FPGA fabric, or where some hardened pipeline is available on the chip. Furthermore, hardened pipeline can also interact with soft logics in FPGA. The Xilinx DRM KMS module is to integrate multiple subdevices and to represent the entire pipeline as a single DRM device. The module includes helper (ex, framebuffer and gem helpers) and glue logic (ex, crtc interface) functions. Signed-off-by: Hyun Kwon Acked-by: Daniel Vetter --- v7 - Unbind as component in shutdown - Register release callback for master device v6 - Fix the function desc for pipeline calls - Rebase on drm-misc-next - Fix typos in documentation - Match types for return and internal variables - Remove use of 'tmp' variables - Protect any crtc list iteration with mutex - Remove a check for drm device in crtc unregistration - Split the crtc ops as a separate struct to constify - Embed xlnx_crtc_helper into xlnx_drm - Move to_xlnx_crtc macro close to xlnx_crtc - Remove unneeded include - Replace custom vres module param with CONFIG_DRM_FBDEV_OVERALLOC - Rename crtc to crtc_helper to make it clearer - Use 'DRM device' instead of 'DRM core' - Remove unused function, xlnx_get_format() - Use device instead of platform device for the logical master - Inline xlnx_of_component_probe() - Use of_get_parent() - Remove the port binding handling in the driver - Do complete forward-declarations in headers - Constify all function pointers - Use the default ioctl from fb helper - Return the minimum pitch always - Clean up the duplicate license paragraphs - Get common bits for dma mask instead of minimum value - Remove dummy function declaration from header - Fix a typo in the commit message with some re-organization v5 - Redefine xlnx_pipeline_init() v4 - Fix a bug in of graph binding handling - Remove vblank callbacks from xlnx_crtc - Remove the dt binding. This module becomes more like a library. - Rephrase the commit message v3 - Add Laurent as a maintainer - Fix multiple-reference on gem objects v2 - Change the SPDX identifier format - Merge patches(crtc, gem, fb) into single one v2 of xlnx_drv - Rename kms to display in xlnx_drv - Replace some xlnx specific fb helper with common helpers in xlnx_drv - Don't set the commit tail callback in xlnx_drv - Support 'ports' graph binding in xlnx_drv v2 of xlnx_fb - Remove wrappers in xlnx_fb - Replace some functions with drm core helpers in xlnx_fb --- --- MAINTAINERS | 9 + drivers/gpu/drm/Kconfig | 2 + drivers/gpu/drm/Makefile | 1 + drivers/gpu/drm/xlnx/Kconfig | 12 ++ drivers/gpu/drm/xlnx/Makefile | 2 + drivers/gpu/drm/xlnx/xlnx_crtc.c | 142 +++++++++++++ drivers/gpu/drm/xlnx/xlnx_crtc.h | 83 ++++++++ drivers/gpu/drm/xlnx/xlnx_drv.c | 433 +++++++++++++++++++++++++++++++++++++++ drivers/gpu/drm/xlnx/xlnx_drv.h | 23 +++ drivers/gpu/drm/xlnx/xlnx_fb.c | 249 ++++++++++++++++++++++ drivers/gpu/drm/xlnx/xlnx_fb.h | 27 +++ drivers/gpu/drm/xlnx/xlnx_gem.c | 36 ++++ drivers/gpu/drm/xlnx/xlnx_gem.h | 21 ++ 13 files changed, 1040 insertions(+) create mode 100644 drivers/gpu/drm/xlnx/Kconfig create mode 100644 drivers/gpu/drm/xlnx/Makefile create mode 100644 drivers/gpu/drm/xlnx/xlnx_crtc.c create mode 100644 drivers/gpu/drm/xlnx/xlnx_crtc.h create mode 100644 drivers/gpu/drm/xlnx/xlnx_drv.c create mode 100644 drivers/gpu/drm/xlnx/xlnx_drv.h create mode 100644 drivers/gpu/drm/xlnx/xlnx_fb.c create mode 100644 drivers/gpu/drm/xlnx/xlnx_fb.h create mode 100644 drivers/gpu/drm/xlnx/xlnx_gem.c create mode 100644 drivers/gpu/drm/xlnx/xlnx_gem.h diff --git a/MAINTAINERS b/MAINTAINERS index 07d1576..137efd6 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -4846,6 +4846,15 @@ F: drivers/gpu/drm/etnaviv/ F: include/uapi/drm/etnaviv_drm.h F: Documentation/devicetree/bindings/display/etnaviv/ +DRM DRIVERS FOR XILINX +M: Hyun Kwon +M: Laurent Pinchart +L: dri-devel@lists.freedesktop.org +S: Maintained +F: drivers/gpu/drm/xlnx/ +F: Documentation/devicetree/bindings/display/xlnx/ +T: git git://anongit.freedesktop.org/drm/drm-misc + DRM DRIVERS FOR ZTE ZX M: Shawn Guo L: dri-devel@lists.freedesktop.org diff --git a/drivers/gpu/drm/Kconfig b/drivers/gpu/drm/Kconfig index 10f9f01..ad6891f 100644 --- a/drivers/gpu/drm/Kconfig +++ b/drivers/gpu/drm/Kconfig @@ -304,6 +304,8 @@ source "drivers/gpu/drm/tve200/Kconfig" source "drivers/gpu/drm/xen/Kconfig" +source "drivers/gpu/drm/xlnx/Kconfig" + # Keep legacy drivers last menuconfig DRM_LEGACY diff --git a/drivers/gpu/drm/Makefile b/drivers/gpu/drm/Makefile index 6ae535c..f6672a5 100644 --- a/drivers/gpu/drm/Makefile +++ b/drivers/gpu/drm/Makefile @@ -106,3 +106,4 @@ obj-$(CONFIG_DRM_TINYDRM) += tinydrm/ obj-$(CONFIG_DRM_PL111) += pl111/ obj-$(CONFIG_DRM_TVE200) += tve200/ obj-$(CONFIG_DRM_XEN) += xen/ +obj-$(CONFIG_DRM_XLNX) += xlnx/ diff --git a/drivers/gpu/drm/xlnx/Kconfig b/drivers/gpu/drm/xlnx/Kconfig new file mode 100644 index 0000000..19fd7cd --- /dev/null +++ b/drivers/gpu/drm/xlnx/Kconfig @@ -0,0 +1,12 @@ +config DRM_XLNX + tristate "Xilinx DRM KMS Driver" + depends on DRM && OF + select DRM_KMS_HELPER + select DRM_KMS_CMA_HELPER + select DRM_GEM_CMA_HELPER + help + Xilinx DRM KMS driver. Choose this option if you have + a Xilinx SoCs with hardened display pipeline or soft + display pipeline using Xilinx IPs in FPGA. This module + provides the kernel mode setting functionalities + for Xilinx display drivers. diff --git a/drivers/gpu/drm/xlnx/Makefile b/drivers/gpu/drm/xlnx/Makefile new file mode 100644 index 0000000..c60a281 --- /dev/null +++ b/drivers/gpu/drm/xlnx/Makefile @@ -0,0 +1,2 @@ +xlnx_drm-objs += xlnx_crtc.o xlnx_drv.o xlnx_fb.o xlnx_gem.o +obj-$(CONFIG_DRM_XLNX) += xlnx_drm.o diff --git a/drivers/gpu/drm/xlnx/xlnx_crtc.c b/drivers/gpu/drm/xlnx/xlnx_crtc.c new file mode 100644 index 0000000..06f1d70 --- /dev/null +++ b/drivers/gpu/drm/xlnx/xlnx_crtc.c @@ -0,0 +1,142 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Xilinx DRM crtc driver + * + * Copyright (C) 2017 - 2018 Xilinx, Inc. + * + * Author: Hyun Woo Kwon + */ + +#include + +#include "xlnx_crtc.h" +#include "xlnx_drv.h" + +/* + * Overview + * -------- + * + * The Xilinx CRTC layer is to enable the custom interface to CRTC drivers. + * The interface is used by Xilinx DRM driver where it needs CRTC + * functionality. CRTC drivers should attach the desired callbacks + * to struct xlnx_crtc and register the xlnx_crtc with corresponding + * drm_device. It's highly recommended CRTC drivers register all callbacks + * even though many of them are optional. + * The CRTC helper simply walks through the registered CRTC device, + * and calls the callbacks. + */ + +unsigned int xlnx_crtc_helper_get_align(struct xlnx_crtc_helper *helper) +{ + struct xlnx_crtc *crtc; + unsigned int align = 1; + + mutex_lock(&helper->lock); + list_for_each_entry(crtc, &helper->xlnx_crtcs, list) { + if (crtc->ops->get_align) + align = ALIGN(align, crtc->ops->get_align(crtc)); + } + mutex_unlock(&helper->lock); + + return align; +} + +u64 xlnx_crtc_helper_get_dma_mask(struct xlnx_crtc_helper *helper) +{ + struct xlnx_crtc *crtc; + u64 mask = DMA_BIT_MASK(sizeof(dma_addr_t) * 8); + + mutex_lock(&helper->lock); + list_for_each_entry(crtc, &helper->xlnx_crtcs, list) { + if (crtc->ops->get_dma_mask) + mask &= crtc->ops->get_dma_mask(crtc); + } + mutex_unlock(&helper->lock); + + return mask; +} + +int xlnx_crtc_helper_get_max_width(struct xlnx_crtc_helper *helper) +{ + struct xlnx_crtc *crtc; + int width = S32_MAX; + + mutex_lock(&helper->lock); + list_for_each_entry(crtc, &helper->xlnx_crtcs, list) { + if (crtc->ops->get_max_width) + width = min(width, crtc->ops->get_max_width(crtc)); + } + mutex_unlock(&helper->lock); + + return width; +} + +int xlnx_crtc_helper_get_max_height(struct xlnx_crtc_helper *helper) +{ + struct xlnx_crtc *crtc; + int height = S32_MAX; + + mutex_lock(&helper->lock); + list_for_each_entry(crtc, &helper->xlnx_crtcs, list) { + if (crtc->ops->get_max_height) + height = min(height, crtc->ops->get_max_height(crtc)); + } + mutex_unlock(&helper->lock); + + return height; +} + +u32 xlnx_crtc_helper_get_format(struct xlnx_crtc_helper *helper) +{ + struct xlnx_crtc *crtc; + u32 result = 0, format; + + mutex_lock(&helper->lock); + list_for_each_entry(crtc, &helper->xlnx_crtcs, list) { + if (crtc->ops->get_format) { + format = crtc->ops->get_format(crtc); + if (result && result != format) { + mutex_unlock(&helper->lock); + return 0; + } + result = format; + } + } + mutex_unlock(&helper->lock); + + return result; +} + +void xlnx_crtc_helper_init(struct xlnx_crtc_helper *helper) +{ + INIT_LIST_HEAD(&helper->xlnx_crtcs); + mutex_init(&helper->lock); +} + +void xlnx_crtc_helper_fini(struct xlnx_crtc_helper *helper) +{ + if (WARN_ON(!list_empty(&helper->xlnx_crtcs))) + return; + + mutex_destroy(&helper->lock); +} + +void xlnx_crtc_register(struct drm_device *drm, struct xlnx_crtc *crtc) +{ + struct xlnx_crtc_helper *helper = xlnx_get_crtc_helper(drm); + + mutex_lock(&helper->lock); + list_add_tail(&crtc->list, &helper->xlnx_crtcs); + mutex_unlock(&helper->lock); +} +EXPORT_SYMBOL_GPL(xlnx_crtc_register); + +void xlnx_crtc_unregister(struct drm_device *drm, struct xlnx_crtc *crtc) +{ + struct xlnx_crtc_helper *helper = xlnx_get_crtc_helper(drm); + + mutex_lock(&helper->lock); + list_del(&crtc->list); + mutex_unlock(&helper->lock); +} +EXPORT_SYMBOL_GPL(xlnx_crtc_unregister); diff --git a/drivers/gpu/drm/xlnx/xlnx_crtc.h b/drivers/gpu/drm/xlnx/xlnx_crtc.h new file mode 100644 index 0000000..a6b5f59 --- /dev/null +++ b/drivers/gpu/drm/xlnx/xlnx_crtc.h @@ -0,0 +1,83 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Xilinx DRM crtc header + * + * Copyright (C) 2017 - 2018 Xilinx, Inc. + * + * Author: Hyun Woo Kwon + */ + +#ifndef _XLNX_CRTC_H_ +#define _XLNX_CRTC_H_ + +#include +#include +#include + +struct drm_device; +struct xlnx_crtc; + +/** + * struct xlnx_crtc_ops - Xilinx CRTC operations + * @get_align: Get the alignment requirement of CRTC device + * @get_dma_mask: Get the dma mask of CRTC device + * @get_max_width: Get the maximum supported width + * @get_max_height: Get the maximum supported height + * @get_format: Get the current format of CRTC device + */ +struct xlnx_crtc_ops { + unsigned int (*get_align)(struct xlnx_crtc *crtc); + u64 (*get_dma_mask)(struct xlnx_crtc *crtc); + int (*get_max_width)(struct xlnx_crtc *crtc); + int (*get_max_height)(struct xlnx_crtc *crtc); + u32 (*get_format)(struct xlnx_crtc *crtc); +}; + +/** + * struct xlnx_crtc - Xilinx CRTC device + * @crtc: DRM CRTC device + * @list: list node for Xilinx CRTC device list + * @ops: Xilinx CRTC ops + */ +struct xlnx_crtc { + struct drm_crtc crtc; + struct list_head list; + const struct xlnx_crtc_ops *ops; +}; + +static inline struct xlnx_crtc *to_xlnx_crtc(struct drm_crtc *crtc) +{ + return container_of(crtc, struct xlnx_crtc, crtc); +} + +/* + * Helper functions: used within Xlnx DRM + */ + +/** + * struct xlnx_crtc_helper - Xilinx CRTC helper + * @xlnx_crtcs: list of Xilinx CRTC devices + * @lock: lock to protect @xlnx_crtcs + */ +struct xlnx_crtc_helper { + struct list_head xlnx_crtcs; + struct mutex lock; /* lock for @xlnx_crtcs */ +}; + +unsigned int xlnx_crtc_helper_get_align(struct xlnx_crtc_helper *helper); +u64 xlnx_crtc_helper_get_dma_mask(struct xlnx_crtc_helper *helper); +int xlnx_crtc_helper_get_max_width(struct xlnx_crtc_helper *helper); +int xlnx_crtc_helper_get_max_height(struct xlnx_crtc_helper *helper); +u32 xlnx_crtc_helper_get_format(struct xlnx_crtc_helper *helper); + +void xlnx_crtc_helper_init(struct xlnx_crtc_helper *helper); +void xlnx_crtc_helper_fini(struct xlnx_crtc_helper *helper); + +/* + * CRTC registration: used by other sub-driver modules + */ + +void xlnx_crtc_register(struct drm_device *drm, struct xlnx_crtc *crtc); +void xlnx_crtc_unregister(struct drm_device *drm, struct xlnx_crtc *crtc); + +#endif /* _XLNX_CRTC_H_ */ diff --git a/drivers/gpu/drm/xlnx/xlnx_drv.c b/drivers/gpu/drm/xlnx/xlnx_drv.c new file mode 100644 index 0000000..5ad2dc2 --- /dev/null +++ b/drivers/gpu/drm/xlnx/xlnx_drv.c @@ -0,0 +1,433 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Xilinx DRM KMS Driver + * + * Copyright (C) 2013 - 2018 Xilinx, Inc. + * + * Author: Hyun Woo Kwon + */ + +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +#include "xlnx_crtc.h" +#include "xlnx_fb.h" +#include "xlnx_gem.h" + +#define DRIVER_NAME "xlnx" +#define DRIVER_DESC "Xilinx DRM KMS Driver" +#define DRIVER_DATE "20130509" +#define DRIVER_MAJOR 1 +#define DRIVER_MINOR 0 + +/** + * struct xlnx_drm - Xilinx DRM private data + * @drm: DRM device + * @crtc_helper: Helper to access Xilinx CRTCs + * @fb: DRM fb helper + * @master: logical master device for pipeline + * @suspend_state: atomic state for suspend / resume + */ +struct xlnx_drm { + struct drm_device *drm; + struct xlnx_crtc_helper crtc_helper; + struct drm_fb_helper *fb; + struct device *master; + struct drm_atomic_state *suspend_state; +}; + +/** + * xlnx_get_crtc_helper - Return the crtc helper instance + * @drm: DRM device + * + * Return: the crtc helper instance + */ +struct xlnx_crtc_helper *xlnx_get_crtc_helper(struct drm_device *drm) +{ + struct xlnx_drm *xlnx_drm = drm->dev_private; + + return &xlnx_drm->crtc_helper; +} + +/** + * xlnx_get_align - Return the align requirement through CRTC helper + * @drm: DRM device + * + * Return: the alignment requirement + */ +unsigned int xlnx_get_align(struct drm_device *drm) +{ + struct xlnx_drm *xlnx_drm = drm->dev_private; + + return xlnx_crtc_helper_get_align(&xlnx_drm->crtc_helper); +} + +static void xlnx_output_poll_changed(struct drm_device *drm) +{ + struct xlnx_drm *xlnx_drm = drm->dev_private; + + if (xlnx_drm->fb) + drm_fb_helper_hotplug_event(xlnx_drm->fb); +} + +static const struct drm_mode_config_funcs xlnx_mode_config_funcs = { + .fb_create = xlnx_fb_create, + .output_poll_changed = xlnx_output_poll_changed, + .atomic_check = drm_atomic_helper_check, + .atomic_commit = drm_atomic_helper_commit, +}; + +static void xlnx_mode_config_init(struct drm_device *drm) +{ + struct xlnx_drm *xlnx_drm = drm->dev_private; + struct xlnx_crtc_helper *crtc_helper = &xlnx_drm->crtc_helper; + + drm->mode_config.min_width = 0; + drm->mode_config.min_height = 0; + drm->mode_config.max_width = + xlnx_crtc_helper_get_max_width(crtc_helper); + drm->mode_config.max_height = + xlnx_crtc_helper_get_max_height(crtc_helper); +} + +static void xlnx_lastclose(struct drm_device *drm) +{ + struct xlnx_drm *xlnx_drm = drm->dev_private; + + if (xlnx_drm->fb) + drm_fb_helper_restore_fbdev_mode_unlocked(xlnx_drm->fb); +} + +static const struct file_operations xlnx_fops = { + .owner = THIS_MODULE, + .open = drm_open, + .release = drm_release, + .unlocked_ioctl = drm_ioctl, + .mmap = drm_gem_cma_mmap, + .poll = drm_poll, + .read = drm_read, +#ifdef CONFIG_COMPAT + .compat_ioctl = drm_compat_ioctl, +#endif + .llseek = noop_llseek, +}; + +static struct drm_driver xlnx_drm_driver = { + .driver_features = DRIVER_MODESET | DRIVER_GEM | + DRIVER_ATOMIC | DRIVER_PRIME, + .lastclose = xlnx_lastclose, + + .prime_handle_to_fd = drm_gem_prime_handle_to_fd, + .prime_fd_to_handle = drm_gem_prime_fd_to_handle, + .gem_prime_export = drm_gem_prime_export, + .gem_prime_import = drm_gem_prime_import, + .gem_prime_get_sg_table = drm_gem_cma_prime_get_sg_table, + .gem_prime_import_sg_table = drm_gem_cma_prime_import_sg_table, + .gem_prime_vmap = drm_gem_cma_prime_vmap, + .gem_prime_vunmap = drm_gem_cma_prime_vunmap, + .gem_prime_mmap = drm_gem_cma_prime_mmap, + .gem_free_object = drm_gem_cma_free_object, + .gem_vm_ops = &drm_gem_cma_vm_ops, + .dumb_create = xlnx_gem_cma_dumb_create, + .dumb_destroy = drm_gem_dumb_destroy, + + .fops = &xlnx_fops, + + .name = DRIVER_NAME, + .desc = DRIVER_DESC, + .date = DRIVER_DATE, + .major = DRIVER_MAJOR, + .minor = DRIVER_MINOR, +}; + +static int xlnx_bind(struct device *master) +{ + struct xlnx_drm *xlnx_drm; + struct drm_device *drm; + const struct drm_format_info *info; + int ret; + u32 format; + + drm = drm_dev_alloc(&xlnx_drm_driver, master->parent); + if (IS_ERR(drm)) + return PTR_ERR(drm); + + xlnx_drm = devm_kzalloc(drm->dev, sizeof(*xlnx_drm), GFP_KERNEL); + if (!xlnx_drm) { + ret = -ENOMEM; + goto err_drm; + } + + drm_mode_config_init(drm); + drm->mode_config.funcs = &xlnx_mode_config_funcs; + + ret = drm_vblank_init(drm, 1); + if (ret) { + dev_err(master->parent, "failed to initialize vblank\n"); + goto err_xlnx_drm; + } + + drm->irq_enabled = 1; + drm->dev_private = xlnx_drm; + xlnx_drm->drm = drm; + xlnx_drm->master = master; + drm_kms_helper_poll_init(drm); + dev_set_drvdata(master, xlnx_drm); + + xlnx_crtc_helper_init(&xlnx_drm->crtc_helper); + + ret = component_bind_all(master, drm); + if (ret) + goto err_crtc; + + xlnx_mode_config_init(drm); + drm_mode_config_reset(drm); + dma_set_mask(drm->dev, + xlnx_crtc_helper_get_dma_mask(&xlnx_drm->crtc_helper)); + + format = xlnx_crtc_helper_get_format(&xlnx_drm->crtc_helper); + info = drm_format_info(format); + if (info && info->depth && info->cpp[0]) { + unsigned int align; + + align = xlnx_crtc_helper_get_align(&xlnx_drm->crtc_helper); + xlnx_drm->fb = xlnx_fb_init(drm, info->cpp[0] * 8, 1, align); + if (IS_ERR(xlnx_drm->fb)) { + dev_err(master->parent, + "failed to initialize drm fb\n"); + xlnx_drm->fb = NULL; + } + } else { + /* fbdev emulation is optional */ + dev_info(master->parent, "fbdev is not initialized\n"); + } + + ret = drm_dev_register(drm, 0); + if (ret < 0) + goto err_fb; + + return 0; + +err_fb: + if (xlnx_drm->fb) + xlnx_fb_fini(xlnx_drm->fb); + component_unbind_all(drm->dev, drm); +err_crtc: + xlnx_crtc_helper_fini(&xlnx_drm->crtc_helper); +err_xlnx_drm: + drm_mode_config_cleanup(drm); +err_drm: + drm_dev_unref(drm); + return ret; +} + +static void xlnx_unbind(struct device *master) +{ + struct xlnx_drm *xlnx_drm = dev_get_drvdata(master); + struct drm_device *drm = xlnx_drm->drm; + + drm_dev_unregister(drm); + if (xlnx_drm->fb) + xlnx_fb_fini(xlnx_drm->fb); + component_unbind_all(master, drm); + xlnx_crtc_helper_fini(&xlnx_drm->crtc_helper); + drm_kms_helper_poll_fini(drm); + drm_mode_config_cleanup(drm); + drm_dev_unref(drm); +} + +static const struct component_master_ops xlnx_master_ops = { + .bind = xlnx_bind, + .unbind = xlnx_unbind, +}; + +static int xlnx_compare_of(struct device *dev, void *data) +{ + return dev->of_node == data; +} + +static int xlnx_probe(struct device *master_dev) +{ + struct device *dev = master_dev->parent; + struct component_match *match = NULL; + + if (!dev->of_node) + return -EINVAL; + + component_match_add(master_dev, &match, xlnx_compare_of, dev->of_node); + + return component_master_add_with_match(master_dev, &xlnx_master_ops, + match); +} + +static int xlnx_remove(struct device *dev) +{ + component_master_del(dev, &xlnx_master_ops); + return 0; +} + +static void xlnx_shutdown(struct device *dev) +{ + component_master_del(dev, &xlnx_master_ops); +} + +static int __maybe_unused xlnx_pm_suspend(struct device *dev) +{ + struct xlnx_drm *xlnx_drm = dev_get_drvdata(dev); + struct drm_device *drm = xlnx_drm->drm; + + drm_kms_helper_poll_disable(drm); + + xlnx_drm->suspend_state = drm_atomic_helper_suspend(drm); + if (IS_ERR(xlnx_drm->suspend_state)) { + drm_kms_helper_poll_enable(drm); + return PTR_ERR(xlnx_drm->suspend_state); + } + + return 0; +} + +static int __maybe_unused xlnx_pm_resume(struct device *dev) +{ + struct xlnx_drm *xlnx_drm = dev_get_drvdata(dev); + struct drm_device *drm = xlnx_drm->drm; + + drm_atomic_helper_resume(drm, xlnx_drm->suspend_state); + drm_kms_helper_poll_enable(drm); + + return 0; +} + +static const struct dev_pm_ops xlnx_pm_ops = { + SET_SYSTEM_SLEEP_PM_OPS(xlnx_pm_suspend, xlnx_pm_resume) +}; + +static int xlnx_drv_bus_match(struct device *dev, struct device_driver *drv) +{ + return !strncmp(dev_name(dev), drv->name, strlen(drv->name)); +} + +struct bus_type xlnx_driver_bus_type = { + .name = "xlnx-drm-bus", + .match = &xlnx_drv_bus_match, +}; + +static struct device_driver xlnx_driver = { + .probe = xlnx_probe, + .remove = xlnx_remove, + .shutdown = xlnx_shutdown, + .name = "xlnx-drm", + .pm = &xlnx_pm_ops, + .bus = &xlnx_driver_bus_type, + .owner = THIS_MODULE, +}; + +/* bitmap for master id */ +static u32 xlnx_master_ids = GENMASK(31, 0); + +static void xlnx_master_release(struct device *dev) +{ + kfree(dev); +} + +/** + * xlnx_drm_pipeline_init - Initialize the drm pipeline for the device + * @dev: The device to initialize the drm pipeline device + * + * This function initializes the drm pipeline device, struct drm_device, + * on @dev by creating a logical master device. The logical device acts + * as a master device to bind slave devices and represents the entire + * pipeline. + * The logical master uses the port bindings of the calling device to + * figure out the pipeline topology. + * + * Return: the logical master device if the drm device is initialized + * on @dev. Error code otherwise. + */ +struct device *xlnx_drm_pipeline_init(struct device *dev) +{ + struct device *master; + int id, ret; + + id = ffs(xlnx_master_ids); + if (!id) + return ERR_PTR(-ENOSPC); + + master = kzalloc(sizeof(*master), GFP_KERNEL); + if (!master) + return ERR_PTR(-ENOMEM); + device_initialize(master); + master->parent = dev; + master->bus = &xlnx_driver_bus_type; + master->release = xlnx_master_release; + + ret = dev_set_name(master, "xlnx-drm.%d", id); + if (ret) + goto err_kfree; + + ret = device_add(master); + if (ret) + goto err_kfree; + + xlnx_master_ids &= ~BIT(master->id); + return master; + +err_kfree: + kfree(master); + return ERR_PTR(ret); +} +EXPORT_SYMBOL_GPL(xlnx_drm_pipeline_init); + +/** + * xlnx_drm_pipeline_exit - Release the drm pipeline for the device + * @master: The master pipeline device to release + * + * Release the logical pipeline device returned by xlnx_drm_pipeline_init(). + */ +void xlnx_drm_pipeline_exit(struct device *master) +{ + xlnx_master_ids |= BIT(master->id); + device_unregister(master); +} +EXPORT_SYMBOL_GPL(xlnx_drm_pipeline_exit); + +static int __init xlnx_drm_drv_init(void) +{ + int ret; + + ret = bus_register(&xlnx_driver_bus_type); + if (ret) + return ret; + + ret = driver_register(&xlnx_driver); + if (ret) { + bus_unregister(&xlnx_driver_bus_type); + return ret; + } + + return 0; +} + +static void __exit xlnx_drm_drv_exit(void) +{ + bus_unregister(&xlnx_driver_bus_type); + driver_unregister(&xlnx_driver); +} + +module_init(xlnx_drm_drv_init); +module_exit(xlnx_drm_drv_exit); + +MODULE_AUTHOR("Xilinx, Inc."); +MODULE_DESCRIPTION("Xilinx DRM KMS Driver"); +MODULE_LICENSE("GPL v2"); diff --git a/drivers/gpu/drm/xlnx/xlnx_drv.h b/drivers/gpu/drm/xlnx/xlnx_drv.h new file mode 100644 index 0000000..b38ff2a --- /dev/null +++ b/drivers/gpu/drm/xlnx/xlnx_drv.h @@ -0,0 +1,23 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Xilinx DRM KMS Header for Xilinx + * + * Copyright (C) 2013 - 2018 Xilinx, Inc. + * + * Author: Hyun Woo Kwon + */ + +#ifndef _XLNX_DRV_H_ +#define _XLNX_DRV_H_ + +struct device; +struct drm_device; +struct xlnx_crtc_helper; + +struct device *xlnx_drm_pipeline_init(struct device *parent); +void xlnx_drm_pipeline_exit(struct device *pipeline); + +unsigned int xlnx_get_align(struct drm_device *drm); +struct xlnx_crtc_helper *xlnx_get_crtc_helper(struct drm_device *drm); + +#endif /* _XLNX_DRV_H_ */ diff --git a/drivers/gpu/drm/xlnx/xlnx_fb.c b/drivers/gpu/drm/xlnx/xlnx_fb.c new file mode 100644 index 0000000..8e8ab14 --- /dev/null +++ b/drivers/gpu/drm/xlnx/xlnx_fb.c @@ -0,0 +1,249 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Xilinx DRM KMS Framebuffer helper + * + * Copyright (C) 2015 - 2018 Xilinx, Inc. + * + * Author: Hyun Woo Kwon + * + * Based on drm_fb_cma_helper.c + * + * Copyright (C) 2012 Analog Device Inc. + */ + +#include +#include +#include +#include +#include +#include + +#include "xlnx_drv.h" +#include "xlnx_fb.h" + +#define XLNX_MAX_PLANES 4 + +struct xlnx_fbdev { + struct drm_fb_helper fb_helper; + struct drm_framebuffer *fb; + unsigned int align; +}; + +static inline struct xlnx_fbdev *to_fbdev(struct drm_fb_helper *fb_helper) +{ + return container_of(fb_helper, struct xlnx_fbdev, fb_helper); +} + +static const struct drm_framebuffer_funcs xlnx_fb_funcs = { + .destroy = drm_gem_fb_destroy, + .create_handle = drm_gem_fb_create_handle, +}; + +static struct fb_ops xlnx_fbdev_ops = { + .owner = THIS_MODULE, + .fb_fillrect = sys_fillrect, + .fb_copyarea = sys_copyarea, + .fb_imageblit = sys_imageblit, + DRM_FB_HELPER_DEFAULT_OPS, +}; + +/** + * xlnx_fbdev_create - Create the fbdev with a framebuffer + * @fb_helper: fb helper structure + * @size: framebuffer size info + * + * This function is based on drm_fbdev_cma_create(). + * + * Return: 0 if successful, or the error code. + */ +static int xlnx_fbdev_create(struct drm_fb_helper *fb_helper, + struct drm_fb_helper_surface_size *size) +{ + struct xlnx_fbdev *fbdev = to_fbdev(fb_helper); + struct drm_device *drm = fb_helper->dev; + struct drm_gem_cma_object *obj; + struct drm_framebuffer *fb; + unsigned int bytes_per_pixel; + unsigned long offset; + struct fb_info *fbi; + size_t bytes; + int ret; + + dev_dbg(drm->dev, "surface width(%d), height(%d) and bpp(%d)\n", + size->surface_width, size->surface_height, size->surface_bpp); + + bytes_per_pixel = DIV_ROUND_UP(size->surface_bpp, 8); + bytes = ALIGN(size->surface_width * bytes_per_pixel, fbdev->align); + bytes *= size->surface_height; + + obj = drm_gem_cma_create(drm, bytes); + if (IS_ERR(obj)) + return PTR_ERR(obj); + + fbi = framebuffer_alloc(0, drm->dev); + if (!fbi) { + dev_err(drm->dev, "Failed to allocate framebuffer info.\n"); + ret = -ENOMEM; + goto err_drm_gem_cma_free_object; + } + + fbdev->fb = drm_gem_fbdev_fb_create(drm, size, fbdev->align, &obj->base, + &xlnx_fb_funcs); + if (IS_ERR(fbdev->fb)) { + dev_err(drm->dev, "Failed to allocate DRM framebuffer.\n"); + ret = PTR_ERR(fbdev->fb); + goto err_framebuffer_release; + } + + fb = fbdev->fb; + fb_helper->fb = fb; + fb_helper->fbdev = fbi; + fbi->par = fb_helper; + fbi->flags = FBINFO_FLAG_DEFAULT; + fbi->fbops = &xlnx_fbdev_ops; + + ret = fb_alloc_cmap(&fbi->cmap, 256, 0); + if (ret) { + dev_err(drm->dev, "Failed to allocate color map.\n"); + goto err_fb_destroy; + } + + drm_fb_helper_fill_fix(fbi, fb->pitches[0], fb->format->depth); + drm_fb_helper_fill_var(fbi, fb_helper, size->fb_width, size->fb_height); + + offset = fbi->var.xoffset * bytes_per_pixel; + offset += fbi->var.yoffset * fb->pitches[0]; + + drm->mode_config.fb_base = (resource_size_t)obj->paddr; + fbi->screen_base = (char __iomem *)(obj->vaddr + offset); + fbi->fix.smem_start = (unsigned long)(obj->paddr + offset); + fbi->screen_size = bytes; + fbi->fix.smem_len = bytes; + + return 0; + +err_fb_destroy: + drm_framebuffer_unregister_private(fb); + drm_gem_fb_destroy(fb); +err_framebuffer_release: + framebuffer_release(fbi); +err_drm_gem_cma_free_object: + drm_gem_cma_free_object(&obj->base); + return ret; +} + +static const struct drm_fb_helper_funcs xlnx_fb_helper_funcs = { + .fb_probe = xlnx_fbdev_create, +}; + +/** + * xlnx_fb_init - Allocate and initializes the Xilinx framebuffer + * @drm: DRM device + * @preferred_bpp: preferred bits per pixel for the device + * @max_conn_count: maximum number of connectors + * @align: alignment value for pitch + * + * This function is based on drm_fbdev_cma_init(). + * + * Return: a newly allocated drm_fb_helper struct or a ERR_PTR. + */ +struct drm_fb_helper * +xlnx_fb_init(struct drm_device *drm, int preferred_bpp, + unsigned int max_conn_count, unsigned int align) +{ + struct xlnx_fbdev *fbdev; + struct drm_fb_helper *fb_helper; + int ret; + + fbdev = kzalloc(sizeof(*fbdev), GFP_KERNEL); + if (!fbdev) + return ERR_PTR(-ENOMEM); + + fbdev->align = align; + fb_helper = &fbdev->fb_helper; + drm_fb_helper_prepare(drm, fb_helper, &xlnx_fb_helper_funcs); + + ret = drm_fb_helper_init(drm, fb_helper, max_conn_count); + if (ret < 0) { + dev_err(drm->dev, "Failed to initialize drm fb helper.\n"); + goto err_free; + } + + ret = drm_fb_helper_single_add_all_connectors(fb_helper); + if (ret < 0) { + dev_err(drm->dev, "Failed to add connectors.\n"); + goto err_drm_fb_helper_fini; + } + + ret = drm_fb_helper_initial_config(fb_helper, preferred_bpp); + if (ret < 0) { + dev_err(drm->dev, "Failed to set initial hw configuration.\n"); + goto err_drm_fb_helper_fini; + } + + return fb_helper; + +err_drm_fb_helper_fini: + drm_fb_helper_fini(fb_helper); +err_free: + kfree(fbdev); + return ERR_PTR(ret); +} + +/** + * xlnx_fbdev_defio_fini - Free the defio fb + * @fbi: fb_info struct + * + * This function is based on drm_fbdev_cma_defio_fini(). + */ +static void xlnx_fbdev_defio_fini(struct fb_info *fbi) +{ + if (!fbi->fbdefio) + return; + + fb_deferred_io_cleanup(fbi); + kfree(fbi->fbdefio); + kfree(fbi->fbops); +} + +/** + * xlnx_fbdev_fini - Free the Xilinx framebuffer + * @fb_helper: drm_fb_helper struct + * + * This function is based on drm_fbdev_cma_fini(). + */ +void xlnx_fb_fini(struct drm_fb_helper *fb_helper) +{ + struct xlnx_fbdev *fbdev = to_fbdev(fb_helper); + + drm_fb_helper_unregister_fbi(&fbdev->fb_helper); + if (fbdev->fb_helper.fbdev) + xlnx_fbdev_defio_fini(fbdev->fb_helper.fbdev); + + if (fbdev->fb_helper.fb) + drm_framebuffer_remove(fbdev->fb_helper.fb); + + drm_fb_helper_fini(&fbdev->fb_helper); + kfree(fbdev); +} + +/** + * xlnx_fb_create - (struct drm_mode_config_funcs *)->fb_create callback + * @drm: DRM device + * @file_priv: drm file private data + * @mode_cmd: mode command for fb creation + * + * This functions creates a drm_framebuffer with xlnx_fb_funcs for given mode + * @mode_cmd. This functions is intended to be used for the fb_create callback + * function of drm_mode_config_funcs. + * + * Return: a drm_framebuffer object if successful, or + * ERR_PTR from drm_gem_fb_create_with_funcs(). + */ +struct drm_framebuffer * +xlnx_fb_create(struct drm_device *drm, struct drm_file *file_priv, + const struct drm_mode_fb_cmd2 *mode_cmd) +{ + return drm_gem_fb_create_with_funcs(drm, file_priv, mode_cmd, + &xlnx_fb_funcs); +} diff --git a/drivers/gpu/drm/xlnx/xlnx_fb.h b/drivers/gpu/drm/xlnx/xlnx_fb.h new file mode 100644 index 0000000..e41738e --- /dev/null +++ b/drivers/gpu/drm/xlnx/xlnx_fb.h @@ -0,0 +1,27 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Xilinx DRM KMS Framebuffer helper header + * + * Copyright (C) 2015 - 2018 Xilinx, Inc. + * + * Author: Hyun Woo Kwon + */ + +#ifndef _XLNX_FB_H_ +#define _XLNX_FB_H_ + +struct drm_device; +struct drm_file; +struct drm_fb_helper; +struct drm_framebuffer; +struct drm_mode_fb_cmd2; + +struct drm_framebuffer * +xlnx_fb_create(struct drm_device *drm, struct drm_file *file_priv, + const struct drm_mode_fb_cmd2 *mode_cmd); +struct drm_fb_helper * +xlnx_fb_init(struct drm_device *drm, int preferred_bpp, + unsigned int max_conn_count, unsigned int align); +void xlnx_fb_fini(struct drm_fb_helper *fb_helper); + +#endif /* _XLNX_FB_H_ */ diff --git a/drivers/gpu/drm/xlnx/xlnx_gem.c b/drivers/gpu/drm/xlnx/xlnx_gem.c new file mode 100644 index 0000000..6748dc1 --- /dev/null +++ b/drivers/gpu/drm/xlnx/xlnx_gem.c @@ -0,0 +1,36 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Xilinx DRM KMS GEM helper + * + * Copyright (C) 2015 - 2018 Xilinx, Inc. + * + * Author: Hyun Woo Kwon + */ + +#include +#include + +#include "xlnx_drv.h" +#include "xlnx_gem.h" + +/* + * xlnx_gem_cma_dumb_create - (struct drm_driver)->dumb_create callback + * @file_priv: drm_file object + * @drm: DRM object + * @args: info for dumb scanout buffer creation + * + * This function is for dumb_create callback of drm_driver struct. Simply + * it wraps around drm_gem_cma_dumb_create() and sets the pitch value + * by retrieving the value from the device. + * + * Return: The return value from drm_gem_cma_dumb_create() + */ +int xlnx_gem_cma_dumb_create(struct drm_file *file_priv, struct drm_device *drm, + struct drm_mode_create_dumb *args) +{ + unsigned int pitch = DIV_ROUND_UP(args->width * args->bpp, 8); + + args->pitch = ALIGN(pitch, xlnx_get_align(drm)); + + return drm_gem_cma_dumb_create_internal(file_priv, drm, args); +} diff --git a/drivers/gpu/drm/xlnx/xlnx_gem.h b/drivers/gpu/drm/xlnx/xlnx_gem.h new file mode 100644 index 0000000..3c9ed5f --- /dev/null +++ b/drivers/gpu/drm/xlnx/xlnx_gem.h @@ -0,0 +1,21 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Xilinx DRM KMS GEM helper header + * + * Copyright (C) 2015 - 2018 Xilinx, Inc. + * + * Author: Hyun Woo Kwon + */ + +#ifndef _XLNX_GEM_H_ +#define _XLNX_GEM_H_ + +struct drm_device; +struct drm_file; +struct drm_mode_create_dumb; + +int xlnx_gem_cma_dumb_create(struct drm_file *file_priv, + struct drm_device *drm, + struct drm_mode_create_dumb *args); + +#endif /* _XLNX_GEM_H_ */