Subject: [PATCH] [acpi video] Add proc interface for video buses - Add these files - info - POST_info - POST - DOS ..with the first two being read-only, and the latter two being read-write (and providing interface for users to write hex values to files to directly control the POST and DOS settings.. ugh!) The ROM file was not added, as it was not even implemented in the legacy driver. Signed-off-by: Patrick Mochel --- drivers/acpi/drivers/video/bus-proc.c | 160 +++++++++++++++++++++++++++++++++ 1 files changed, 159 insertions(+), 1 deletions(-) applies-to: 6ad7d2cf592830212a811ad0f1a69a2a6f5f839d db10372e21bf1af210024b4578be3e45d0d4dd1d diff --git a/drivers/acpi/drivers/video/bus-proc.c b/drivers/acpi/drivers/video/bus-proc.c index 8297c84..3894bab 100644 --- a/drivers/acpi/drivers/video/bus-proc.c +++ b/drivers/acpi/drivers/video/bus-proc.c @@ -12,4 +12,162 @@ #include "video.h" -acpi_driver_proc_none(video_bus); +static int read_info(struct seq_file * seq, void * offset) +{ + struct acpi_dev * ad = seq->private; + struct acpi_video_bus * vb = dev_get_drvdata(&ad->dev); + + seq_printf(seq, "Switching heads: %s\n", + vb->v_can_switch ? "yes" : "no"); + seq_printf(seq, "Video ROM: %s\n", + vb->v_has_rom ? "yes" : "no"); + seq_printf(seq, "Device to be POSTed on boot: %s\n", + vb->v_can_post ? "yes" : "no"); + + return 0; +} + +static int open_info(struct inode * inode, struct file * file) +{ + return single_open(file, read_info, PDE(inode)->data); +} + + +static int read_POST_info(struct seq_file * seq, void * offset) +{ + struct acpi_dev * ad = seq->private; + struct acpi_video_bus * vb = dev_get_drvdata(&ad->dev); + + if (vb->v_post_options) { + seq_printf(seq, "can POST:%s%s%s\n", + vb->v_post_options & ACPI_VIDEO_BUS_POST_INTEGRATED ? + " " : "", + vb->v_post_options & ACPI_VIDEO_BUS_POST_PCI ? + " " : "", + vb->v_post_options & ACPI_VIDEO_BUS_POST_AGP ? + " " : ""); + } else + seq_printf(seq, "\n"); + + return 0; +} + +static int open_POST_info(struct inode * inode, struct file * file) +{ + return single_open(file, read_POST_info, PDE(inode)->data); +} + + +static int read_POST(struct seq_file * seq, void * offset) +{ + struct acpi_dev * ad = seq->private; + struct acpi_video_bus * vb = dev_get_drvdata(&ad->dev); + + /* + * FIXME: This is different than the original driver. + * + * There was inconsistency in the mask values of that driver: + * The values returned from _VPO were different than those returned + * by _GPD. + * + * This code has been changed to match the code above, assuming there + * is consistency in the spec. BUT, it may be that the old driver was + * correct... + */ + + if (vb->v_post_id) { + seq_printf(seq, "device posted is: %s%s%s\n", + vb->v_post_id & ACPI_VIDEO_BUS_POST_INTEGRATED ? + " motherboard VGA device" : "" , + vb->v_post_id & ACPI_VIDEO_BUS_POST_PCI ? + " PCI VGA device" : "" , + vb->v_post_id & ACPI_VIDEO_BUS_POST_AGP ? + " AGP VGA device" : ""); + } else + seq_printf(seq, "\n"); + + return 0; +} + +static ssize_t write_POST(struct file *file, const char __user * buffer, + size_t count, loff_t * ppos) +{ + struct seq_file * m = file->private_data; + struct acpi_dev * ad = m->private; + struct acpi_video_bus * vb = dev_get_drvdata(&ad->dev); + unsigned long new_post; + char str[12] = ""; + char * end; + int ret; + + if (count < 1 || count >= sizeof(str)) + return -EINVAL; + + if (copy_from_user(str, buffer, count)) + return -EFAULT; + + new_post = strtoul(str, &end, 0); + if (*end != '\0') + return -EINVAL; + + ret = video_bus_set_post(vb, new_post); + + return ret == 0 ? count : ret; +} + +static int open_POST(struct inode * inode, struct file * file) +{ + return single_open(file, read_POST, PDE(inode)->data); +} + + +static int read_DOS(struct seq_file * seq, void * offset) +{ + struct acpi_dev * ad = seq->private; + struct acpi_video_bus * vb = dev_get_drvdata(&ad->dev); + + seq_printf(seq, "DOS setting: <%d>\n", vb->v_dos); + return 0; +} + +static ssize_t write_DOS(struct file *file, const char __user * buffer, + size_t count, loff_t * ppos) +{ + struct seq_file * m = file->private_data; + struct acpi_dev * ad = m->private; + struct acpi_video_bus * vb = dev_get_drvdata(&ad->dev); + + unsigned long new_post; + char str[12] = ""; + char * end; + int ret; + + if (count < 1 || count >= sizeof(str)) + return -EINVAL; + + if (copy_from_user(str, buffer, count)) + return -EFAULT; + + new_post = strtoul(str, &end, 0); + if (*end != '\0') + return -EINVAL; + + ret = video_bus_set_post(vb, new_post); + + return ret == 0 ? count : ret; +} + +static int open_DOS(struct inode * inode, struct file * file) +{ + return single_open(file, read_DOS, PDE(inode)->data); +} + + +static struct acpi_proc_file video_bus_files[] = { + proc_file_ro(info), + proc_file_ro(POST_info), + proc_file_rw(POST), + proc_file_rw(DOS), +}; + +acpi_driver_proc_name(video_bus, "video"); --- 0.99.9.GIT