From patchwork Sun Apr 7 10:52:57 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?UmFmYcWCIE1pxYJlY2tp?= X-Patchwork-Id: 2402931 Return-Path: X-Original-To: patchwork-dri-devel@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by patchwork2.kernel.org (Postfix) with ESMTP id C1F65DF2A1 for ; Sun, 7 Apr 2013 10:54:12 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id B4909E5F39 for ; Sun, 7 Apr 2013 03:54:12 -0700 (PDT) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-ea0-f169.google.com (mail-ea0-f169.google.com [209.85.215.169]) by gabe.freedesktop.org (Postfix) with ESMTP id EE87AE5F8B for ; Sun, 7 Apr 2013 03:53:10 -0700 (PDT) Received: by mail-ea0-f169.google.com with SMTP id n15so1922299ead.28 for ; Sun, 07 Apr 2013 03:53:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:from:to:cc:subject:date:message-id:x-mailer; bh=Z4Vk+0ah1Ce6Hlw9h9OZGi++UD8jG1aUUYeBpE79H/E=; b=TLwv7u5uwHSnKSVuQQ4GZ851ctjZAnnKCdUzUd5z7IGCQ5rr5zBI7u+rYBQ2mtqjhj YxbPgrjWdSLv9BbS3xUA1cAkltujpV858/uvFSjBYXrn8ty91Q4TOvdPLxrbLfL06Oky mGncr8M+RMvM9Rf0B19s1G78kbW0Gz3Felmr9E932CArRkcD2kNcugMe+tiUpM9HyYcH XaZmoj7rZi7QE4CMEWRNAHlDJpu/dewNzIyxVCi64wZD9FbdETBOS3XeYHvzP+m+gGm0 k73vfDEraqI5gU19XtilKo19zrMAzy1O7VfSVxFRuLiewPOaYusq+FhPFDK0rkyadQLA hIHA== X-Received: by 10.14.3.70 with SMTP id 46mr37809758eeg.2.1365331989976; Sun, 07 Apr 2013 03:53:09 -0700 (PDT) Received: from linux-samsung700g7a.lan (ip-194-187-74-233.konfederacka.maverick.com.pl. [194.187.74.233]) by mx.google.com with ESMTPS id a1sm25647762eep.2.2013.04.07.03.53.07 (version=TLSv1.2 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sun, 07 Apr 2013 03:53:08 -0700 (PDT) From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= To: dri-devel@lists.freedesktop.org, Dave Airlie , Alex Deucher , =?UTF-8?q?Christian=20K=C3=B6nig?= Subject: [RFC][PATCH] drm: add helper extracting SADs from EDID Date: Sun, 7 Apr 2013 12:52:57 +0200 Message-Id: <1365331977-5622-1-git-send-email-zajec5@gmail.com> X-Mailer: git-send-email 1.7.10.4 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: dri-devel-bounces+patchwork-dri-devel=patchwork.kernel.org@lists.freedesktop.org Errors-To: dri-devel-bounces+patchwork-dri-devel=patchwork.kernel.org@lists.freedesktop.org Some devices (ATI/AMD cards) don't want passing ELD struct to the hardware but just require filling specific registers and then hardware/firmware does the rest. In such a cases we need to read info from SAD blocks and put them in the correct registers. --- drivers/gpu/drm/drm_edid.c | 55 ++++++++++++++++++++++++++++++++++++++++++++ include/drm/drm_edid.h | 24 +++++++++++++++++++ 2 files changed, 79 insertions(+) diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c index e2acfdb..7c9e799 100644 --- a/drivers/gpu/drm/drm_edid.c +++ b/drivers/gpu/drm/drm_edid.c @@ -2511,6 +2511,61 @@ void drm_edid_to_eld(struct drm_connector *connector, struct edid *edid) EXPORT_SYMBOL(drm_edid_to_eld); /** + * drm_edid_to_sad - extracts SADs from EDID + * @edid: EDID to parse + * + * Looks for CEA EDID block and extracts SADs (Short Audio Descriptors) from it. + */ +struct cea_sad *drm_edid_to_sad(struct edid *edid) +{ + struct cea_sad *sads = NULL; + int i, start, end, dbl; + u8 *db, *cea; + + cea = drm_find_cea_extension(edid); + if (!cea) { + DRM_DEBUG_KMS("SAD: no CEA Extension found\n"); + return NULL; + } + + if (cea_revision(cea) < 3) { + DRM_DEBUG_KMS("SAD: wrong CEA revision\n"); + return NULL; + } + + if (cea_db_offsets(cea, &start, &end)) { + DRM_DEBUG_KMS("SAD: invalid data block offsets\n"); + return NULL; + } + + for_each_cea_db(cea, i, start, end) { + db = &cea[i]; + dbl = cea_db_payload_len(db); + + if (cea_db_tag(db) == AUDIO_BLOCK) { + int count = dbl / 3; /* SAD is 3B */ + int j; + + sads = kzalloc(count + 1 * sizeof(*sads), GFP_KERNEL); + if (!sads) + return NULL; + + for (j = 0; j < count; j++) { + u8 *sad = &db[1 + j * 3]; + + sads[j].format = (sad[0] & 0x78) >> 3; + sads[j].channels = sad[0] & 0x7; + sads[j].freq = sad[1] & 0x7F; + sads[j].byte2 = sad[2]; + } + } + } + + return sads; +} +EXPORT_SYMBOL(drm_edid_to_sad); + +/** * drm_av_sync_delay - HDMI/DP sink audio-video sync delay in millisecond * @connector: connector associated with the HDMI/DP sink * @mode: the display mode diff --git a/include/drm/drm_edid.h b/include/drm/drm_edid.h index 5da1b4a..b36d052 100644 --- a/include/drm/drm_edid.h +++ b/include/drm/drm_edid.h @@ -244,12 +244,36 @@ struct edid { #define EDID_PRODUCT_ID(e) ((e)->prod_code[0] | ((e)->prod_code[1] << 8)) +#define SAD_FORMAT_LPCM 0x01 +#define SAD_FORMAT_AC3 0x02 +#define SAD_FORMAT_MPEG1 0x03 +#define SAD_FORMAT_MP3 0x04 +#define SAD_FORMAT_MPEG2 0x05 +#define SAD_FORMAT_AAC 0x06 +#define SAD_FORMAT_DTS 0x07 +#define SAD_FORMAT_ATRAC 0x08 +#define SAD_FORMAT_ONE_BIT_AUDIO 0x09 +#define SAD_FORMAT_DOLBY_DIGITAL 0x0a +#define SAD_FORMAT_DTS_HD 0x0b +#define SAD_FORMAT_MAT_MLP 0x0c +#define SAD_FORMAT_DST 0x0d +#define SAD_FORMAT_WMA_PRO 0x0e + +/* Short Audio Descriptor */ +struct cea_sad { + u8 format; + u8 channels; /* max number of channels - 1 */ + u8 freq; + u8 byte2; /* meaning depends on format */ +}; + struct drm_encoder; struct drm_connector; struct drm_display_mode; struct hdmi_avi_infoframe; void drm_edid_to_eld(struct drm_connector *connector, struct edid *edid); +struct cea_sad *drm_edid_to_sad(struct edid *edid); int drm_av_sync_delay(struct drm_connector *connector, struct drm_display_mode *mode); struct drm_connector *drm_select_eld(struct drm_encoder *encoder,