1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * Copyright 2011 Florian Tobias Schandinat <FlorianSchandinat@gmx.de>
9 #include <linux/slab.h>
15 static const char *name = "EDID";
18 static void query_edid(struct via_aux_drv *drv)
20 struct fb_monspecs *spec = drv->data;
21 unsigned char edid[EDID_LENGTH];
25 fb_destroy_modedb(spec->modedb);
27 spec = kmalloc(sizeof(*spec), GFP_KERNEL);
32 spec->version = spec->revision = 0;
33 if (via_aux_read(drv, 0x00, edid, EDID_LENGTH)) {
34 fb_edid_to_monspecs(edid, spec);
35 valid = spec->version || spec->revision;
42 printk(KERN_DEBUG "EDID: %s %s\n", spec->manufacturer, spec->monitor);
47 static const struct fb_videomode *get_preferred_mode(struct via_aux_drv *drv)
49 struct fb_monspecs *spec = drv->data;
52 if (!spec || !spec->modedb || !(spec->misc & FB_MISC_1ST_DETAIL))
55 for (i = 0; i < spec->modedb_len; i++) {
56 if (spec->modedb[i].flag & FB_MODE_IS_FIRST &&
57 spec->modedb[i].flag & FB_MODE_IS_DETAILED)
58 return &spec->modedb[i];
64 static void cleanup(struct via_aux_drv *drv)
66 struct fb_monspecs *spec = drv->data;
69 fb_destroy_modedb(spec->modedb);
72 void via_aux_edid_probe(struct via_aux_bus *bus)
74 struct via_aux_drv drv = {
79 .get_preferred_mode = get_preferred_mode};
83 /* as EDID devices can be connected/disconnected just add the driver */