From patchwork Mon Nov 18 10:18:31 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Wayne Lin X-Patchwork-Id: 11260731 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 4AADD930 for ; Mon, 25 Nov 2019 17:13:30 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 30848207FD for ; Mon, 25 Nov 2019 17:13:30 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 30848207FD Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=amd.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=intel-gfx-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id B314D89C61; Mon, 25 Nov 2019 17:13:29 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by gabe.freedesktop.org (Postfix) with ESMTPS id 5CBA689E5B for ; Mon, 25 Nov 2019 15:44:29 +0000 (UTC) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga105.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 25 Nov 2019 07:44:28 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.69,241,1571727600"; d="scan'208";a="216953629" Received: from stinkbox.fi.intel.com (HELO stinkbox) ([10.237.72.174]) by fmsmga001.fm.intel.com with SMTP; 25 Nov 2019 07:44:26 -0800 Received: by stinkbox (sSMTP sendmail emulation); Mon, 25 Nov 2019 17:44:26 +0200 Resent-From: Ville =?iso-8859-1?q?Syrj=E4l=E4?= Resent-Date: Mon, 25 Nov 2019 17:44:26 +0200 Resent-Message-ID: <20191125154426.GY1208@intel.com> Resent-To: intel-gfx@lists.freedesktop.org X-Original-To: ville.syrjala@linux.intel.com Delivered-To: ville.syrjala@linux.intel.com Received: from linux.intel.com [10.54.29.200] by stinkbox.fi.intel.com with IMAP (fetchmail-6.3.26) for (single-drop); Mon, 18 Nov 2019 12:19:08 +0200 (EET) Received: from fmsmga006.fm.intel.com (fmsmga006.fm.intel.com [10.253.24.20]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by linux.intel.com (Postfix) with ESMTPS id ADD8458049A for ; Mon, 18 Nov 2019 02:19:02 -0800 (PST) Received: from orsmga102-1.jf.intel.com (HELO mga09.intel.com) ([10.7.208.27]) by fmsmga006-1.fm.intel.com with ESMTP; 18 Nov 2019 02:19:02 -0800 IronPort-PHdr: 9a23:AdsNgRHelRlVUEL33rL4gp1GYnF76YWxBRYc798cs5wLar6qrsbrOUCZ7vJo3geQDNfrrslcgu+TiJjOHGkJ4JKPqncHIc5FUhNDgsITzVR5XZy1THbjJfuvVBQUWcRPUFg5oCOdGG0NRIPFQQSXpXe/qzkPBh/4KAx5YPzvHZLfhNi20Ob0/IDPZwJPh3y2ZrYgdRg= X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A0E5BAAdb9Jdh0RGayhlHgELHINJUF4TdQMENYNqQINIhTuFNppeglIDGDwJAQEBAQEBAQEBBgEBIwwBAQKEPoJDBQIENBMCDgEBAQMBAQECAQIDBAICEAEBAQgNCQgphT4Mg0c5MgEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQUCDVQrQBAGEQQLAQ0BAREmARgcAiYCXwENBSKDAAGCRgMuAQICCpMVkGQCgTiIXwEBdH8zgn4BAQWBNAGBFII2GFiBPwMGCQGBBCiHPIYxP4ERgmRsh1WCXo1aiUqXCQeCLXGGKY4pJ5oRjkiIOJFQAgICAgQFAg4BAQWBaYF7MxojUIJsUBEUkRoMDgmDUIUUhUw2MYwiK4ITAQE X-IPAS-Result: A0E5BAAdb9Jdh0RGayhlHgELHINJUF4TdQMENYNqQINIhTuFNppeglIDGDwJAQEBAQEBAQEBBgEBIwwBAQKEPoJDBQIENBMCDgEBAQMBAQECAQIDBAICEAEBAQgNCQgphT4Mg0c5MgEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQUCDVQrQBAGEQQLAQ0BAREmARgcAiYCXwENBSKDAAGCRgMuAQICCpMVkGQCgTiIXwEBdH8zgn4BAQWBNAGBFII2GFiBPwMGCQGBBCiHPIYxP4ERgmRsh1WCXo1aiUqXCQeCLXGGKY4pJ5oRjkiIOJFQAgICAgQFAg4BAQWBaYF7MxojUIJsUBEUkRoMDgmDUIUUhUw2MYwiK4ITAQE X-IronPort-AV: E=Sophos;i="5.68,319,1569308400"; d="scan'208";a="107652842" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from mail-eopbgr700068.outbound.protection.outlook.com (HELO NAM04-SN1-obe.outbound.protection.outlook.com) ([40.107.70.68]) by mtab.intel.com with ESMTP/TLS/AES256-GCM-SHA384; 18 Nov 2019 02:19:01 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=OdFlrUy2oTMOOY2vnB4cjgd5Cnzu7KGMhDsRq5ftPHB2AsK9svsHb4BDstiCFCf/pIFBXOmL7hSu7VLYIQXsr4e4N2OPbKcUvfo/927dMZRor0LH401la9ZI10eMzddxh3pT0Au04/b1ANrmS4yEQVZALz5Bb9gYcu4dwSyabPao5VeX4m8GsnG6MLjEeKg4s3COagzQ9PsKl65W6tIGjAP4oXZE8rdG6k9BlH2hTSH50r6MTVExtqvVHWUlgCxyuMKu2K8jYnqbojEG0aXqOqFiWfgFh5QKP73mhJgHdkI5NntANJMdBOXR9cwgkzvT7FHk0QWb+Oc7LMGhiHKCxw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=T3tzqLP7TlwPrfuFSoVbzph3Vvyz7gTYj6y1QORXYaM=; b=BRDyrfOKiz824kV/WVg18taEwhlCZZsm6y7w3ZjfNIqHNkzDn98w9IKI0Jg6poWs78ciRMrOb6jz5y59vG71xgbyRaIbDrMFXRVMULNKqtCdQTXjYMDzFJVNWOU90tk0nA5957VYNWw30XXzvvIG2pO8uh2YqKZ0+QAI4+88J8EheMR70nmHMFAYiMYN1YdfFUE0kCAwR/YSRm/O4SZdgLAS0GNRtYN6Y5ngQHXz8FOSnXAhOK5oanlc4oUsZBJmx/CxGTHPVEmc4mGa4ULZgluoG4ZD8d0KnrcchX3M7ckC/VKwh2n4JLtrnXrrvUWWfW+0y2+Casel4JTFh95QrQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none (sender ip is 165.204.84.17) smtp.rcpttodomain=lists.freedesktop.org smtp.mailfrom=amd.com; dmarc=permerror action=none header.from=amd.com; dkim=none (message not signed); arc=none Received: from BN8PR12CA0018.namprd12.prod.outlook.com (2603:10b6:408:60::31) by DM6PR12MB3291.namprd12.prod.outlook.com (2603:10b6:5:186::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2451.30; Mon, 18 Nov 2019 10:18:56 +0000 Received: from BN8NAM11FT012.eop-nam11.prod.protection.outlook.com (2a01:111:f400:7eae::208) by BN8PR12CA0018.outlook.office365.com (2603:10b6:408:60::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.2451.23 via Frontend Transport; Mon, 18 Nov 2019 10:18:55 +0000 Received: from SATLEXMB01.amd.com (165.204.84.17) by BN8NAM11FT012.mail.protection.outlook.com (10.13.177.55) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.20.2451.23 via Frontend Transport; Mon, 18 Nov 2019 10:18:55 +0000 Received: from SATLEXMB01.amd.com (10.181.40.142) by SATLEXMB01.amd.com (10.181.40.142) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1713.5; Mon, 18 Nov 2019 04:18:55 -0600 Received: from wayne-System-Product-Name.amd.com (10.180.168.240) by SATLEXMB01.amd.com (10.181.40.142) with Microsoft SMTP Server id 15.1.1713.5 via Frontend Transport; Mon, 18 Nov 2019 04:18:54 -0600 From: Wayne Lin To: , Date: Mon, 18 Nov 2019 18:18:31 +0800 Message-ID: <20191118101832.15487-1-Wayne.Lin@amd.com> X-Mailer: git-send-email 2.17.1 MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-HT: Tenant X-Forefront-Antispam-Report: CIP:165.204.84.17; IPV:NLI; CTRY:US; EFV:NLI; SFV:NSPM; SFS:(10009020)(979002)(4636009)(346002)(376002)(396003)(39860400002)(136003)(428003)(189003)(199004)(1076003)(966005)(4326008)(305945005)(47776003)(70586007)(70206006)(336012)(426003)(2906002)(2870700001)(126002)(476003)(6306002)(53416004)(50466002)(478600001)(50226002)(54906003)(316002)(110136005)(2616005)(356004)(6666004)(5820100001)(186003)(8936002)(23676004)(7696005)(486006)(5660300002)(8676002)(26005)(36756003)(81156014)(81166006)(86362001)(969003)(989001)(999001)(1009001)(1019001); DIR:OUT; SFP:1101; SCL:1; SRVR:DM6PR12MB3291; H:SATLEXMB01.amd.com; FPR:; SPF:None; LANG:en; PTR:InfoDomainNonexistent; MX:1; A:1; X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 5089cbaa-df84-4feb-95b2-08d76c10b7f0 X-MS-TrafficTypeDiagnostic: DM6PR12MB3291: X-MS-Exchange-PUrlCount: 1 X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:8273; X-Forefront-PRVS: 0225B0D5BC X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 221/8ND6zxP+pxCRKE8j/KfcaBH2g+wFPpnoRSjzTDV3rhC/o5bvFwzl7Gg4oqEwTNXsMs5duBm7k8T5QiXgqQrz45gdhiU2lhRsNb3nszrBzMy5R5MNwfB5BIl1W0mN9Z6d8d3oU/MRU0iEws6hfJ1w4kCq2vPIDj5ymmfyzqEmcdFvNakFDc43dz8xpbTyjNoH6zWk7/EtOfRj1kvK+7QF70nA6X1+vYdsElfFtAa/v5mILdygWdRM0BpSu4wwtiBlCa3gt7sK/W4l0BgGXu+15rw4Kif+Ht2k0VGWD7+BGerwBxohfRJD24C+rG41yP4tWpNf8RH/GYZVZh0TV7K1+q1w0OLhCQtvj9Hku8Ut+izHj3KwzUbxxsYdmNc3Lmldhiu5qMRsI9ytNdidY992d373tRAslqS8Z2yU0ju3rB+K7DyrqxQihoR6UrPNa+gL+HTU0GpPY5yRspH8e1P8PMNxVk971HtTpZkckHM= X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Nov 2019 10:18:55.7058 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 5089cbaa-df84-4feb-95b2-08d76c10b7f0 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d; Ip=[165.204.84.17]; Helo=[SATLEXMB01.amd.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR12MB3291 X-Mailman-Approved-At: Mon, 25 Nov 2019 17:13:20 +0000 X-Mailman-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amdcloud.onmicrosoft.com; s=selector2-amdcloud-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=T3tzqLP7TlwPrfuFSoVbzph3Vvyz7gTYj6y1QORXYaM=; b=j57lRK4bdt+fC8mMaz1ZO2sU6U8/siQP/halZ0qn0tT5UsaKj062hRjtAc5qoHq4bBvMSy7uQ22FxamfDiQqcHq8vfAEO0BpwuZbezyhQ29DM0JXebFEr7BU+1/inpUYhjjYs3kbga60tkq9vz/WFKb8GpvgOL6YXB0dngznkyo= X-Mailman-Original-Authentication-Results: mtab.intel.com; spf=None smtp.pra=Wayne.Lin@amd.com; spf=None smtp.mailfrom=Wayne.Lin@amd.com; spf=Pass smtp.helo=postmaster@NAM04-SN1-obe.outbound.protection.outlook.com; dkim=pass (signature verified) header.i=@amdcloud.onmicrosoft.com Subject: [Intel-gfx] [PATCH V2 1/2] drm/edid: Add aspect ratios to HDMI 4K modes X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Wayne Lin Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" [Why] HDMI 2.0 adds aspect ratio attribute to distinguish different 4k modes. According to Appendix E of HDMI 2.0 spec, source should use VSIF to indicate video mode only when the mode is one defined in HDMI 1.4b 4K modes. Otherwise, use AVI infoframes to convey VIC. Current code doesn't take aspect ratio into consideration while constructing avi infoframe. Should modify that. [How] Inherit Ville Syrjälä's work "drm/edid: Prep for HDMI VIC aspect ratio" at https://patchwork.kernel.org/patch/11174639/ Add picture_aspect_ratio attributes to edid_4k_modes[] and construct VIC and HDMI_VIC by taking aspect ratio into consideration. v2: Correct missing initializer error at adding aspect ratio of SMPTE mode. Signed-off-by: Wayne Lin --- drivers/gpu/drm/drm_edid.c | 45 +++++++++++++++++++++++++++++--------- 1 file changed, 35 insertions(+), 10 deletions(-) diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c index 77a39fc76045..0307cad36f14 100644 --- a/drivers/gpu/drm/drm_edid.c +++ b/drivers/gpu/drm/drm_edid.c @@ -1288,25 +1288,25 @@ static const struct drm_display_mode edid_4k_modes[] = { 3840, 4016, 4104, 4400, 0, 2160, 2168, 2178, 2250, 0, DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC), - .vrefresh = 30, }, + .vrefresh = 30, .picture_aspect_ratio = HDMI_PICTURE_ASPECT_16_9, }, /* 2 - 3840x2160@25Hz */ { DRM_MODE("3840x2160", DRM_MODE_TYPE_DRIVER, 297000, 3840, 4896, 4984, 5280, 0, 2160, 2168, 2178, 2250, 0, DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC), - .vrefresh = 25, }, + .vrefresh = 25, .picture_aspect_ratio = HDMI_PICTURE_ASPECT_16_9, }, /* 3 - 3840x2160@24Hz */ { DRM_MODE("3840x2160", DRM_MODE_TYPE_DRIVER, 297000, 3840, 5116, 5204, 5500, 0, 2160, 2168, 2178, 2250, 0, DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC), - .vrefresh = 24, }, + .vrefresh = 24, .picture_aspect_ratio = HDMI_PICTURE_ASPECT_16_9, }, /* 4 - 4096x2160@24Hz (SMPTE) */ { DRM_MODE("4096x2160", DRM_MODE_TYPE_DRIVER, 297000, 4096, 5116, 5204, 5500, 0, 2160, 2168, 2178, 2250, 0, DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC), - .vrefresh = 24, }, + .vrefresh = 24, .picture_aspect_ratio = HDMI_PICTURE_ASPECT_256_135, }, }; /*** DDC fetch and block validation ***/ @@ -3110,6 +3110,11 @@ static enum hdmi_picture_aspect drm_get_cea_aspect_ratio(const u8 video_code) return edid_cea_modes[video_code].picture_aspect_ratio; } +static enum hdmi_picture_aspect drm_get_hdmi_aspect_ratio(const u8 video_code) +{ + return edid_4k_modes[video_code].picture_aspect_ratio; +} + /* * Calculate the alternate clock for HDMI modes (those from the HDMI vendor * specific block). @@ -3136,6 +3141,9 @@ static u8 drm_match_hdmi_mode_clock_tolerance(const struct drm_display_mode *to_ if (!to_match->clock) return 0; + if (to_match->picture_aspect_ratio) + match_flags |= DRM_MODE_MATCH_ASPECT_RATIO; + for (vic = 1; vic < ARRAY_SIZE(edid_4k_modes); vic++) { const struct drm_display_mode *hdmi_mode = &edid_4k_modes[vic]; unsigned int clock1, clock2; @@ -3171,6 +3179,9 @@ static u8 drm_match_hdmi_mode(const struct drm_display_mode *to_match) if (!to_match->clock) return 0; + if (to_match->picture_aspect_ratio) + match_flags |= DRM_MODE_MATCH_ASPECT_RATIO; + for (vic = 1; vic < ARRAY_SIZE(edid_4k_modes); vic++) { const struct drm_display_mode *hdmi_mode = &edid_4k_modes[vic]; unsigned int clock1, clock2; @@ -5118,6 +5129,7 @@ drm_hdmi_avi_infoframe_from_display_mode(struct hdmi_avi_infoframe *frame, const struct drm_display_mode *mode) { enum hdmi_picture_aspect picture_aspect; + u8 vic, hdmi_vic; int err; if (!frame || !mode) @@ -5130,7 +5142,8 @@ drm_hdmi_avi_infoframe_from_display_mode(struct hdmi_avi_infoframe *frame, if (mode->flags & DRM_MODE_FLAG_DBLCLK) frame->pixel_repeat = 1; - frame->video_code = drm_mode_cea_vic(connector, mode); + vic = drm_mode_cea_vic(connector, mode); + hdmi_vic = drm_mode_hdmi_vic(connector, mode); frame->picture_aspect = HDMI_PICTURE_ASPECT_NONE; @@ -5144,11 +5157,15 @@ drm_hdmi_avi_infoframe_from_display_mode(struct hdmi_avi_infoframe *frame, /* * Populate picture aspect ratio from either - * user input (if specified) or from the CEA mode list. + * user input (if specified) or from the CEA/HDMI mode lists. */ picture_aspect = mode->picture_aspect_ratio; - if (picture_aspect == HDMI_PICTURE_ASPECT_NONE) - picture_aspect = drm_get_cea_aspect_ratio(frame->video_code); + if (picture_aspect == HDMI_PICTURE_ASPECT_NONE) { + if (vic) + picture_aspect = drm_get_cea_aspect_ratio(vic); + else if (hdmi_vic) + picture_aspect = drm_get_hdmi_aspect_ratio(hdmi_vic); + } /* * The infoframe can't convey anything but none, 4:3 @@ -5156,12 +5173,20 @@ drm_hdmi_avi_infoframe_from_display_mode(struct hdmi_avi_infoframe *frame, * we can only satisfy it by specifying the right VIC. */ if (picture_aspect > HDMI_PICTURE_ASPECT_16_9) { - if (picture_aspect != - drm_get_cea_aspect_ratio(frame->video_code)) + if (vic) { + if (picture_aspect != drm_get_cea_aspect_ratio(vic)) + return -EINVAL; + } else if (hdmi_vic) { + if (picture_aspect != drm_get_hdmi_aspect_ratio(hdmi_vic)) + return -EINVAL; + } else { return -EINVAL; + } + picture_aspect = HDMI_PICTURE_ASPECT_NONE; } + frame->video_code = vic; frame->picture_aspect = picture_aspect; frame->active_aspect = HDMI_ACTIVE_ASPECT_PICTURE; frame->scan_mode = HDMI_SCAN_MODE_UNDERSCAN;