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: "Lin, Wayne" X-Patchwork-Id: 11249283 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 AFED6913 for ; Mon, 18 Nov 2019 10:19:04 +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 97C7920679 for ; Mon, 18 Nov 2019 10:19:04 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 97C7920679 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=amd.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 243D889CF9; Mon, 18 Nov 2019 10:19:02 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from NAM04-SN1-obe.outbound.protection.outlook.com (mail-eopbgr700048.outbound.protection.outlook.com [40.107.70.48]) by gabe.freedesktop.org (Postfix) with ESMTPS id D216289700; Mon, 18 Nov 2019 10:19:00 +0000 (UTC) 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-SPF: None (protection.outlook.com: amd.com does not designate permitted sender hosts) 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: , Subject: [PATCH V2 1/2] drm/edid: Add aspect ratios to HDMI 4K modes 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-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: spf=none (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; lists.freedesktop.org; dkim=none (message not signed) header.d=none;lists.freedesktop.org; dmarc=permerror action=none header.from=amd.com; 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: Wayne Lin Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" [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;