mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-01-15 09:34:17 +00:00
drm/edid: add drm_edid_print_product_id()
Add a function to print a decoded EDID vendor and product id to a drm printer, optionally with the raw data. v2: - refactor date printing - use seq_buf to avoid kasprintf() (Ville) - handle week == 0 (Ville) - use be16_to_cpu() on manufacturer_name Cc: Ville Syrjälä <ville.syrjala@linux.intel.com> Acked-by: Melissa Wen <mwen@igalia.com> # v1 Reviewed-by: Ville Syrjälä <ville.syrjala@linux.intel.com> Link: https://patchwork.freedesktop.org/patch/msgid/32bbc83ee6557809ef6d7a5edb1bc8ef4d56d10f.1712655867.git.jani.nikula@intel.com Signed-off-by: Jani Nikula <jani.nikula@intel.com>
This commit is contained in:
parent
3ddbd34553
commit
3f56e5514b
@ -29,12 +29,14 @@
|
||||
*/
|
||||
|
||||
#include <linux/bitfield.h>
|
||||
#include <linux/byteorder/generic.h>
|
||||
#include <linux/cec.h>
|
||||
#include <linux/hdmi.h>
|
||||
#include <linux/i2c.h>
|
||||
#include <linux/kernel.h>
|
||||
#include <linux/module.h>
|
||||
#include <linux/pci.h>
|
||||
#include <linux/seq_buf.h>
|
||||
#include <linux/slab.h>
|
||||
#include <linux/vga_switcheroo.h>
|
||||
|
||||
@ -2771,6 +2773,48 @@ void drm_edid_get_product_id(const struct drm_edid *drm_edid,
|
||||
}
|
||||
EXPORT_SYMBOL(drm_edid_get_product_id);
|
||||
|
||||
static void decode_date(struct seq_buf *s, const struct drm_edid_product_id *id)
|
||||
{
|
||||
int week = id->week_of_manufacture;
|
||||
int year = id->year_of_manufacture + 1990;
|
||||
|
||||
if (week == 0xff)
|
||||
seq_buf_printf(s, "model year: %d", year);
|
||||
else if (!week)
|
||||
seq_buf_printf(s, "year of manufacture: %d", year);
|
||||
else
|
||||
seq_buf_printf(s, "week/year of manufacture: %d/%d", week, year);
|
||||
}
|
||||
|
||||
/**
|
||||
* drm_edid_print_product_id - Print decoded product id to printer
|
||||
* @p: drm printer
|
||||
* @id: EDID product id
|
||||
* @raw: If true, also print the raw hex
|
||||
*
|
||||
* See VESA E-EDID 1.4 section 3.4.
|
||||
*/
|
||||
void drm_edid_print_product_id(struct drm_printer *p,
|
||||
const struct drm_edid_product_id *id, bool raw)
|
||||
{
|
||||
DECLARE_SEQ_BUF(date, 40);
|
||||
char vend[4];
|
||||
|
||||
drm_edid_decode_mfg_id(be16_to_cpu(id->manufacturer_name), vend);
|
||||
|
||||
decode_date(&date, id);
|
||||
|
||||
drm_printf(p, "manufacturer name: %s, product code: %u, serial number: %u, %s\n",
|
||||
vend, le16_to_cpu(id->product_code),
|
||||
le32_to_cpu(id->serial_number), seq_buf_str(&date));
|
||||
|
||||
if (raw)
|
||||
drm_printf(p, "raw product id: %*ph\n", (int)sizeof(*id), id);
|
||||
|
||||
WARN_ON(seq_buf_has_overflowed(&date));
|
||||
}
|
||||
EXPORT_SYMBOL(drm_edid_print_product_id);
|
||||
|
||||
/**
|
||||
* drm_edid_get_panel_id - Get a panel's ID from EDID
|
||||
* @drm_edid: EDID that contains panel ID.
|
||||
|
@ -30,6 +30,7 @@ struct drm_connector;
|
||||
struct drm_device;
|
||||
struct drm_display_mode;
|
||||
struct drm_edid;
|
||||
struct drm_printer;
|
||||
struct hdmi_avi_infoframe;
|
||||
struct hdmi_vendor_infoframe;
|
||||
struct i2c_adapter;
|
||||
@ -481,6 +482,8 @@ int drm_edid_connector_add_modes(struct drm_connector *connector);
|
||||
bool drm_edid_is_digital(const struct drm_edid *drm_edid);
|
||||
void drm_edid_get_product_id(const struct drm_edid *drm_edid,
|
||||
struct drm_edid_product_id *id);
|
||||
void drm_edid_print_product_id(struct drm_printer *p,
|
||||
const struct drm_edid_product_id *id, bool raw);
|
||||
|
||||
const u8 *drm_find_edid_extension(const struct drm_edid *drm_edid,
|
||||
int ext_id, int *ext_index);
|
||||
|
Loading…
x
Reference in New Issue
Block a user