| 1 | |
| 2 | |
| 3 | * Copyright © 2023 Intel Corporation
|
| 4 |
|
| 5 |
|
| 6 | #include <linux/export.h>
|
| 7 |
|
| 8 | #include <drm/drm_edid.h>
|
| 9 | #include <drm/drm_eld.h>
|
| 10 |
|
| 11 | #include "drm_crtc_internal.h"
|
| 12 |
|
| 13 | |
| 14 | * drm_eld_sad_get - get SAD from ELD to struct cea_sad
|
| 15 | * @eld: ELD buffer
|
| 16 | * @sad_index: SAD index
|
| 17 | * @cta_sad: destination struct cea_sad
|
| 18 | *
|
| 19 | * @return: 0 on success, or negative on errors
|
| 20 |
|
| 21 | int drm_eld_sad_get(const u8 *eld, int sad_index, struct cea_sad *cta_sad)
|
| 22 | {
|
| 23 | const u8 *sad;
|
| 24 |
|
| 25 | if (sad_index >= drm_eld_sad_count(eld))
|
| 26 | return -EINVAL;
|
| 27 |
|
| 28 | sad = eld + DRM_ELD_CEA_SAD(drm_eld_mnl(eld), sad_index);
|
| 29 |
|
| 30 | drm_edid_cta_sad_set(cta_sad, sad);
|
| 31 |
|
| 32 | return 0;
|
| 33 | }
|
| 34 | EXPORT_SYMBOL(drm_eld_sad_get);
|
| 35 |
|
| 36 | |
| 37 | * drm_eld_sad_set - set SAD to ELD from struct cea_sad
|
| 38 | * @eld: ELD buffer
|
| 39 | * @sad_index: SAD index
|
| 40 | * @cta_sad: source struct cea_sad
|
| 41 | *
|
| 42 | * @return: 0 on success, or negative on errors
|
| 43 |
|
| 44 | int drm_eld_sad_set(u8 *eld, int sad_index, const struct cea_sad *cta_sad)
|
| 45 | {
|
| 46 | u8 *sad;
|
| 47 |
|
| 48 | if (sad_index >= drm_eld_sad_count(eld))
|
| 49 | return -EINVAL;
|
| 50 |
|
| 51 | sad = eld + DRM_ELD_CEA_SAD(drm_eld_mnl(eld), sad_index);
|
| 52 |
|
| 53 | drm_edid_cta_sad_get(cta_sad, sad);
|
| 54 |
|
| 55 | return 0;
|
| 56 | }
|
| 57 | EXPORT_SYMBOL(drm_eld_sad_set);
|