Re: [patch] ACPI video driver output switch sysfs support

2007-05-09 Thread Len Brown
On Wednesday 09 May 2007 09:07, Luming Yu wrote:
> To use this patch, you need enable VIDEO_OUTPUT_CONTROL and ACPI_VIDEO.
> After loading output.ko and video.ko, you would have
> /sys/class/video_output and several device acpi_videoNum there. For
> example, I got acpi_video0, acpi_video1,acpi_video2,and acpi_video3
> under /sys/class/video_output on my T40.
> I can query the status of  output device0 by running " cat
> /sys/class/video_output/acpi_video0
> " The return value is defined in ACPI SPEC B.5.5 _DCS(Return the
> Status of Output Device).  Also you can turn off video1 and turn on
> video0  by " echo 0 > acpi_video1; echo 0x8000 > acpi_video0".
> Please reference ACPI SPEC  B.5.7 _DSS for the parameter definition.
> Also please note that it may or may NOT works purely depending on if
> your vendor providing correct ACPI video extension support in bios.
> the driver output.ko and video.ko just works like a interface to
> invoke BIOS.

This is a step in the right direction,
but nothing in a generic sysfs location should depend on
bit encodings from the ACPI spec.

eg. from user-space they should be something simple like
0 - disabled
1 - enabled

on read, they should probably query _DCS, and decode its
bit pattern so that again the user sees:
0 - disabled
1 - enabled

I'll put this patch in the test tree now b/c
I want folks to be able to test _DSS,
so feel free to send an incremental patch
on top of this one.

thanks,
-Len
-
To unsubscribe from this list: send the line "unsubscribe linux-acpi" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [patch] ACPI video driver output switch sysfs support

2007-05-09 Thread Luming Yu

To use this patch, you need enable VIDEO_OUTPUT_CONTROL and ACPI_VIDEO.
After loading output.ko and video.ko, you would have
/sys/class/video_output and several device acpi_videoNum there. For
example, I got acpi_video0, acpi_video1,acpi_video2,and acpi_video3
under /sys/class/video_output on my T40.
I can query the status of  output device0 by running " cat
/sys/class/video_output/acpi_video0
" The return value is defined in ACPI SPEC B.5.5 _DCS(Return the
Status of Output Device).  Also you can turn off video1 and turn on
video0  by " echo 0 > acpi_video1; echo 0x8000 > acpi_video0".
Please reference ACPI SPEC  B.5.7 _DSS for the parameter definition.
Also please note that it may or may NOT works purely depending on if
your vendor providing correct ACPI video extension support in bios.
the driver output.ko and video.ko just works like a interface to
invoke BIOS.

The update patch:

Add output switch sysfs class support for ACPI video driver.

signed-off-by: Luming Yu <[EMAIL PROTECTED]>


acpi/Kconfig   |2 +-
acpi/video.c   |   40 
video/Kconfig  |7 +++
video/Makefile |3 +++
4 files changed, 51 insertions(+), 1 deletion(-)

diff --git a/drivers/acpi/Kconfig b/drivers/acpi/Kconfig
index 139f41f..eb4855f 100644
--- a/drivers/acpi/Kconfig
+++ b/drivers/acpi/Kconfig
@@ -124,7 +124,7 @@ config ACPI_BUTTON

config ACPI_VIDEO
tristate "Video"
-   depends on X86 && BACKLIGHT_CLASS_DEVICE
+   depends on X86 && BACKLIGHT_CLASS_DEVICE && VIDEO_OUTPUT_CONTROL
help
  This driver implement the ACPI Extensions For Display Adapters
  for integrated graphics devices on motherboard, as specified in
diff --git a/drivers/acpi/sleep/main.c b/drivers/acpi/sleep/main.c
diff --git a/drivers/acpi/video.c b/drivers/acpi/video.c
index 00d25b3..39273da 100644
--- a/drivers/acpi/video.c
+++ b/drivers/acpi/video.c
@@ -33,6 +33,7 @@
#include 

#include 
+#include 
#include 

#include 
@@ -169,6 +170,7 @@ struct acpi_video_device {
struct acpi_device *dev;
struct acpi_video_device_brightness *brightness;
struct backlight_device *backlight;
+   struct output_device *output_dev;
};

/* bus */
@@ -272,6 +274,10 @@ static int acpi_video_get_next_level(struct
acpi_video_device *device,
 u32 level_current, u32 event);
static void acpi_video_switch_brightness(struct acpi_video_device *device,
 int event);
+static int acpi_video_device_get_state(struct acpi_video_device *device,
+   unsigned long *state);
+static int acpi_video_output_get(struct output_device *od);
+static int acpi_video_device_set_state(struct acpi_video_device
*device, int state);

/*backlight device sysfs support*/
static int acpi_video_get_brightness(struct backlight_device *bd)
@@ -297,6 +303,28 @@ static struct backlight_ops acpi_backlight_ops = {
.update_status  = acpi_video_set_brightness,
};

+/*video output device sysfs support*/
+static int acpi_video_output_get(struct output_device *od)
+{
+   unsigned long state;
+   struct acpi_video_device *vd =
+   (struct acpi_video_device *)class_get_devdata(&od->class_dev);
+   acpi_video_device_get_state(vd, &state);
+   return (int)state;
+}
+
+static int acpi_video_output_set(struct output_device *od)
+{
+   unsigned long state = od->request_state;
+   struct acpi_video_device *vd=
+   (struct acpi_video_device *)class_get_devdata(&od->class_dev);
+   return acpi_video_device_set_state(vd, state);
+}
+
+static struct output_properties acpi_output_properties = {
+   .set_state = acpi_video_output_set,
+   .get_status = acpi_video_output_get,
+};
/* --
   Video Management
   --
*/
@@ -626,6 +654,17 @@ static void acpi_video_device_find_cap(struct
acpi_video_device *device)

kfree(name);
}
+   if (device->cap._DCS && device->cap._DSS){
+   static int count = 0;
+   char *name;
+   name = kzalloc(MAX_NAME_LEN, GFP_KERNEL);
+   if (!name)
+   return;
+   sprintf(name, "acpi_video%d", count++);
+   device->output_dev = video_output_register(name,
+   NULL, device, &acpi_output_properties);
+   kfree(name);
+   }
return;
}

@@ -1669,6 +1708,7 @@ static int acpi_video_bus_put_one_device(struct
acpi_video_device *device)
ACPI_DEVICE_NOTIFY,
acpi_video_device_notify);
backlight_device_unregister(device->backlight);
+   video_output_unregister(device->output_dev);
return 0;
}

diff --git a/driv

Re: [patch] ACPI video driver output switch sysfs support

2007-04-25 Thread Randy Dunlap
On Wed, 25 Apr 2007 22:06:56 +0800 Luming Yu wrote:

> The update patch:
> 
> Add output switch sysfs class support for ACPI video driver.
> 
> signed-off-by: Luming Yu <[EMAIL PROTECTED]>
> ---
>  acpi/Kconfig   |2 +-
>  acpi/video.c   |   40 
>  video/Kconfig  |7 +++
>  video/Makefile |3 +++
>  4 files changed, 51 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/video/Kconfig b/drivers/video/Kconfig
> index 8372ace..8f2c02b 100644
> --- a/drivers/video/Kconfig
> +++ b/drivers/video/Kconfig
> @@ -6,6 +6,13 @@ menu "Graphics support"
> 
>  source "drivers/video/backlight/Kconfig"
> 
> +config VIDEO_OUTPUT_CONTROL
> + tristate "Lowlevel video output switch controls"
> + default m
> + help
> + This framework adds support for low-level control of the video
> + output switch.

Please indent the 2 lines of help text (only)
with .

>From Documentation/CodingStyle:
Help text is indented with 2 spaces.

(meaning 2 spaces more than the word "help" :)

> +
>  config FB
>   tristate "Support for frame buffer devices"
>   ---help---


---
~Randy
*** Remember to use Documentation/SubmitChecklist when testing your code ***
-
To unsubscribe from this list: send the line "unsubscribe linux-acpi" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [patch] ACPI video driver output switch sysfs support

2007-03-12 Thread Randy.Dunlap
On Tue, 13 Mar 2007, Luming Yu wrote:

> Add output switch sysfs class support for ACPI video driver.
>
>  drivers/acpi/Kconfig |2 +-
>  drivers/acpi/video.c |   38 ++
>  drivers/video/Kconfig|7 +++
>  drivers/video/Makefile   |3 +++
>  include/acpi/processor.h |0
>  5 files changed, 49 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/acpi/video.c b/drivers/acpi/video.c
> index 00d25b3..3456603 100644
> --- a/drivers/acpi/video.c
> +++ b/drivers/acpi/video.c
> @@ -297,6 +299,28 @@ static struct backlight_ops acpi_backlig
> .update_status  = acpi_video_set_brightness,
>  };
>
> +/*video output device sysfs support*/
> +static int acpi_video_output_get(struct output_device *od)
> +{
> +   unsigned long state;
> +   struct acpi_video_device *vd =
> +   (struct acpi_video_device *)class_get_devdata(&od->class_dev);
> +   acpi_video_device_get_state(vd,&state);

Please add a space after comma.

> +   return (int)state;
> +}
> +
> +static int acpi_video_output_set(struct output_device *od)
> +{
> +   unsigned long state = od->request_state;
> +   struct acpi_video_device *vd=
> +   (struct acpi_video_device *)class_get_devdata(&od->class_dev);
> +   return acpi_video_device_set_state(vd,state);

ditto

> +}
> +
> +static struct output_properties acpi_output_properties = {
> +   .set_state = acpi_video_output_set,
> +   .get_status = acpi_video_output_get,
> +};
>  /* --
> Video Management
> --
> */
> diff --git a/drivers/video/Kconfig b/drivers/video/Kconfig
> index 7f5a598..bd76a6c 100644
> --- a/drivers/video/Kconfig
> +++ b/drivers/video/Kconfig
> @@ -6,6 +6,13 @@ menu "Graphics support"
>
>  source "drivers/video/backlight/Kconfig"
>
> +config VIDEO_OUTPUT_CONTROL
> +tristate "Lowlevel video output switch controls"
> +   default m
> +   help
> + This framework adds support for low-level control of the video
> +  output switch.
> +

:(

Please use a tab to indent the tristate, default, and help lines.
Then indent the help text with one tab + 2 spaces.


>  config FB
> tristate "Support for frame buffer devices"
> ---help---

-- 
~Randy
-
To unsubscribe from this list: send the line "unsubscribe linux-acpi" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[patch] ACPI video driver output switch sysfs support

2007-03-12 Thread Luming Yu

Add output switch sysfs class support for ACPI video driver.

signed-off-by: Luming Yu <[EMAIL PROTECTED]>
---
drivers/acpi/Kconfig |2 +-
drivers/acpi/video.c |   38 ++
drivers/video/Kconfig|7 +++
drivers/video/Makefile   |3 +++
include/acpi/processor.h |0
5 files changed, 49 insertions(+), 1 deletion(-)

diff --git a/drivers/acpi/Kconfig b/drivers/acpi/Kconfig
index e2ce4a9..7d1627b 100644
--- a/drivers/acpi/Kconfig
+++ b/drivers/acpi/Kconfig
@@ -124,7 +124,7 @@ config ACPI_BUTTON

config ACPI_VIDEO
   tristate "Video"
-   depends on X86 && BACKLIGHT_CLASS_DEVICE
+   depends on X86 && BACKLIGHT_CLASS_DEVICE && VIDEO_OUTPUT_CONTROL
   help
 This driver implement the ACPI Extensions For Display Adapters
 for integrated graphics devices on motherboard, as specified in
diff --git a/drivers/acpi/video.c b/drivers/acpi/video.c
index 00d25b3..3456603 100644
--- a/drivers/acpi/video.c
+++ b/drivers/acpi/video.c
@@ -33,6 +33,7 @@ #include 
#include 

#include 
+#include 
#include 

#include 
@@ -169,6 +170,7 @@ struct acpi_video_device {
   struct acpi_device *dev;
   struct acpi_video_device_brightness *brightness;
   struct backlight_device *backlight;
+   struct output_device *output_dev;
};

/* bus */
@@ -297,6 +299,28 @@ static struct backlight_ops acpi_backlig
   .update_status  = acpi_video_set_brightness,
};

+/*video output device sysfs support*/
+static int acpi_video_output_get(struct output_device *od)
+{
+   unsigned long state;
+   struct acpi_video_device *vd =
+   (struct acpi_video_device *)class_get_devdata(&od->class_dev);
+   acpi_video_device_get_state(vd,&state);
+   return (int)state;
+}
+
+static int acpi_video_output_set(struct output_device *od)
+{
+   unsigned long state = od->request_state;
+   struct acpi_video_device *vd=
+   (struct acpi_video_device *)class_get_devdata(&od->class_dev);
+   return acpi_video_device_set_state(vd,state);
+}
+
+static struct output_properties acpi_output_properties = {
+   .set_state = acpi_video_output_set,
+   .get_status = acpi_video_output_get,
+};
/* --
   Video Management
   --
*/
@@ -626,6 +650,19 @@ static void acpi_video_device_find_cap(s

   kfree(name);
   }
+   if (device->cap._DCS && device->cap._DSS){
+   unsigned long tmp;
+   static int count = 0;
+   char *name;
+   name = kzalloc(MAX_NAME_LEN, GFP_KERNEL);
+   if (!name)
+   return;
+   sprintf(name, "acpi_video%d", count++);
+   device->output_dev = video_output_register(name,
+   &(data->dev->dev),
+   device, &acpi_output_properties);
+   kfree(name);
+   }
   return;
}

@@ -1669,6 +1706,7 @@ static int acpi_video_bus_put_one_device
   ACPI_DEVICE_NOTIFY,
   acpi_video_device_notify);
   backlight_device_unregister(device->backlight);
+   video_output_unregister(device->output_dev);
   return 0;
}

diff --git a/drivers/video/Kconfig b/drivers/video/Kconfig
index 7f5a598..bd76a6c 100644
--- a/drivers/video/Kconfig
+++ b/drivers/video/Kconfig
@@ -6,6 +6,13 @@ menu "Graphics support"

source "drivers/video/backlight/Kconfig"

+config VIDEO_OUTPUT_CONTROL
+tristate "Lowlevel video output switch controls"
+   default m
+   help
+ This framework adds support for low-level control of the video
+  output switch.
+
config FB
   tristate "Support for frame buffer devices"
   ---help---
diff --git a/drivers/video/Makefile b/drivers/video/Makefile
index 760305c..f5ab032 100644
--- a/drivers/video/Makefile
+++ b/drivers/video/Makefile
@@ -108,3 +108,6 @@ obj-$(CONFIG_FB_OF)   += off

# the test framebuffer is last
obj-$(CONFIG_FB_VIRTUAL)  += vfb.o
+
+#video output switch sysfs driver
+obj-$(CONFIG_VIDEO_OUTPUT_CONTROL) += output.o


video_output.patch
Description: Binary data