Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

drm/edid: add helpers to get/set struct cea_sad from/to 3-byte sad

Add helpers to pack/unpack SADs. Both ways and non-static, as follow-up
work needs them.

v2: Add include to get the declarations

Cc: Mitul Golani <mitulkumar.ajitkumar.golani@intel.com>
Reviewed-by: Mitul Golani <mitulkumar.ajitkumar.golani@intel.com>
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/21d657ca854ce26423b461c0bb71e7a0727ba437.1698747331.git.jani.nikula@intel.com

+31 -9
+25 -9
drivers/gpu/drm/drm_edid.c
··· 46 46 #include <drm/drm_print.h> 47 47 48 48 #include "drm_crtc_internal.h" 49 + #include "drm_internal.h" 49 50 50 51 static int oui(u8 first, u8 second, u8 third) 51 52 { ··· 5509 5508 } 5510 5509 5511 5510 /* 5511 + * Get 3-byte SAD buffer from struct cea_sad. 5512 + */ 5513 + void drm_edid_cta_sad_get(const struct cea_sad *cta_sad, u8 *sad) 5514 + { 5515 + sad[0] = cta_sad->format << 3 | cta_sad->channels; 5516 + sad[1] = cta_sad->freq; 5517 + sad[2] = cta_sad->byte2; 5518 + } 5519 + 5520 + /* 5521 + * Set struct cea_sad from 3-byte SAD buffer. 5522 + */ 5523 + void drm_edid_cta_sad_set(struct cea_sad *cta_sad, const u8 *sad) 5524 + { 5525 + cta_sad->format = (sad[0] & 0x78) >> 3; 5526 + cta_sad->channels = sad[0] & 0x07; 5527 + cta_sad->freq = sad[1] & 0x7f; 5528 + cta_sad->byte2 = sad[2]; 5529 + } 5530 + 5531 + /* 5512 5532 * drm_edid_to_eld - build ELD from EDID 5513 5533 * @connector: connector corresponding to the HDMI/DP sink 5514 5534 * @drm_edid: EDID to parse ··· 5623 5601 cea_db_iter_for_each(db, &iter) { 5624 5602 if (cea_db_tag(db) == CTA_DB_AUDIO) { 5625 5603 struct cea_sad *sads; 5626 - int j; 5604 + int i; 5627 5605 5628 5606 count = cea_db_payload_len(db) / 3; /* SAD is 3B */ 5629 5607 sads = kcalloc(count, sizeof(*sads), GFP_KERNEL); 5630 5608 *psads = sads; 5631 5609 if (!sads) 5632 5610 return -ENOMEM; 5633 - for (j = 0; j < count; j++) { 5634 - const u8 *sad = &db->data[j * 3]; 5635 - 5636 - sads[j].format = (sad[0] & 0x78) >> 3; 5637 - sads[j].channels = sad[0] & 0x7; 5638 - sads[j].freq = sad[1] & 0x7F; 5639 - sads[j].byte2 = sad[2]; 5640 - } 5611 + for (i = 0; i < count; i++) 5612 + drm_edid_cta_sad_set(&sads[i], &db->data[i * 3]); 5641 5613 break; 5642 5614 } 5643 5615 }
+6
drivers/gpu/drm/drm_internal.h
··· 22 22 */ 23 23 24 24 #include <linux/kthread.h> 25 + #include <linux/types.h> 25 26 26 27 #include <drm/drm_ioctl.h> 27 28 #include <drm/drm_vblank.h> ··· 32 31 33 32 #define DRM_IF_VERSION(maj, min) (maj << 16 | min) 34 33 34 + struct cea_sad; 35 35 struct dentry; 36 36 struct dma_buf; 37 37 struct iosys_map; ··· 269 267 void drm_framebuffer_print_info(struct drm_printer *p, unsigned int indent, 270 268 const struct drm_framebuffer *fb); 271 269 void drm_framebuffer_debugfs_init(struct drm_device *dev); 270 + 271 + /* drm_edid.c */ 272 + void drm_edid_cta_sad_get(const struct cea_sad *cta_sad, u8 *sad); 273 + void drm_edid_cta_sad_set(struct cea_sad *cta_sad, const u8 *sad);