Commit ed317307 authored by Jani Nikula's avatar Jani Nikula

drm/edid: convert drm_edid_to_speaker_allocation() to use cea db iter

Use the cea db iterator for speaker allocation. We'll still stop at the
first speaker data block, but not at the first CTA extension if that
doesn't have the info.

Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
Signed-off-by: default avatarJani Nikula <jani.nikula@intel.com>
Reviewed-by: default avatarVille Syrjälä <ville.syrjala@linux.intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/0b9e7f136854055a14b826097160fe0b43b9f3d1.1651569697.git.jani.nikula@intel.com
parent 537d9ed2
...@@ -5069,42 +5069,25 @@ EXPORT_SYMBOL(drm_edid_to_sad); ...@@ -5069,42 +5069,25 @@ EXPORT_SYMBOL(drm_edid_to_sad);
*/ */
int drm_edid_to_speaker_allocation(const struct edid *edid, u8 **sadb) int drm_edid_to_speaker_allocation(const struct edid *edid, u8 **sadb)
{ {
const struct cea_db *db;
struct cea_db_iter iter;
int count = 0; int count = 0;
int i, start, end, dbl;
const u8 *cea;
cea = drm_find_cea_extension(edid);
if (!cea) {
DRM_DEBUG_KMS("SAD: no CEA Extension found\n");
return 0;
}
if (cea_revision(cea) < 3) {
DRM_DEBUG_KMS("SAD: wrong CEA revision\n");
return 0;
}
if (cea_db_offsets(cea, &start, &end)) { cea_db_iter_edid_begin(edid, &iter);
DRM_DEBUG_KMS("SAD: invalid data block offsets\n"); cea_db_iter_for_each(db, &iter) {
return -EPROTO; if (cea_db_tag(db) == CTA_DB_SPEAKER &&
} cea_db_payload_len(db) == 3) {
*sadb = kmemdup(db->data, cea_db_payload_len(db),
for_each_cea_db(cea, i, start, end) { GFP_KERNEL);
const u8 *db = &cea[i];
if (cea_db_tag(db) == CTA_DB_SPEAKER) {
dbl = cea_db_payload_len(db);
/* Speaker Allocation Data Block */
if (dbl == 3) {
*sadb = kmemdup(&db[1], dbl, GFP_KERNEL);
if (!*sadb) if (!*sadb)
return -ENOMEM; return -ENOMEM;
count = dbl; count = cea_db_payload_len(db);
break; break;
} }
} }
} cea_db_iter_end(&iter);
DRM_DEBUG_KMS("Found %d Speaker Allocation Data Blocks\n", count);
return count; return count;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment