2 * Copyright 2011 Florian Tobias Schandinat <FlorianSchandinat@gmx.de>
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public
6 * License as published by the Free Software Foundation;
7 * either version 2, or (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTIES OR REPRESENTATIONS; without even
11 * the implied warranty of MERCHANTABILITY or FITNESS FOR
12 * A PARTICULAR PURPOSE.See the GNU General Public License
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
18 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
24 #include <linux/slab.h>
30 static const char *name
= "EDID";
33 static void query_edid(struct via_aux_drv
*drv
)
35 struct fb_monspecs
*spec
= drv
->data
;
36 unsigned char edid
[EDID_LENGTH
];
40 fb_destroy_modedb(spec
->modedb
);
42 spec
= kmalloc(sizeof(*spec
), GFP_KERNEL
);
47 spec
->version
= spec
->revision
= 0;
48 if (via_aux_read(drv
, 0x00, edid
, EDID_LENGTH
)) {
49 fb_edid_to_monspecs(edid
, spec
);
50 valid
= spec
->version
|| spec
->revision
;
57 printk(KERN_DEBUG
"EDID: %s %s\n", spec
->manufacturer
, spec
->monitor
);
62 static const struct fb_videomode
*get_preferred_mode(struct via_aux_drv
*drv
)
64 struct fb_monspecs
*spec
= drv
->data
;
67 if (!spec
|| !spec
->modedb
|| !(spec
->misc
& FB_MISC_1ST_DETAIL
))
70 for (i
= 0; i
< spec
->modedb_len
; i
++) {
71 if (spec
->modedb
[i
].flag
& FB_MODE_IS_FIRST
&&
72 spec
->modedb
[i
].flag
& FB_MODE_IS_DETAILED
)
73 return &spec
->modedb
[i
];
79 static void cleanup(struct via_aux_drv
*drv
)
81 struct fb_monspecs
*spec
= drv
->data
;
84 fb_destroy_modedb(spec
->modedb
);
87 void via_aux_edid_probe(struct via_aux_bus
*bus
)
89 struct via_aux_drv drv
= {
94 .get_preferred_mode
= get_preferred_mode
};
98 /* as EDID devices can be connected/disconnected just add the driver */