~ubuntu-branches/ubuntu/quantal/linux-lowlatency/quantal

« back to all changes in this revision

Viewing changes to ubuntu/omnibook/display.c

  • Committer: Package Import Robot
  • Author(s): Alessio Igor Bogani
  • Date: 2011-10-26 11:13:05 UTC
  • Revision ID: package-import@ubuntu.com-20111026111305-04kado7d1u2er2rl
Tags: 3.2.0-16.25
Add new lowlatency kernel flavour

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * display.c -- External display (LCD,VGA,TV-OUT) feature
 
3
 * 
 
4
 * This program is free software; you can redistribute it and/or modify it
 
5
 * under the terms of the GNU General Public License as published by the
 
6
 * Free Software Foundation; either version 2, or (at your option) any
 
7
 * later version.
 
8
 * 
 
9
 * This program is distributed in the hope that it will be useful, but
 
10
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 
11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 
12
 * General Public License for more details.
 
13
 *
 
14
 * Written by Soós Péter <sp@osb.hu>, 2002-2004
 
15
 * Modified by Mathieu Bérard <mathieu.berard@crans.org>, 2006
 
16
 */
 
17
 
 
18
#include "omnibook.h"
 
19
#include "hardware.h"
 
20
 
 
21
static const char display_name[][16] = {
 
22
        "Internal LCD",
 
23
        "External VGA",
 
24
        "External TV-OUT",
 
25
        "External DVI",
 
26
};
 
27
 
 
28
static int omnibook_display_read(char *buffer, struct omnibook_operation *io_op)
 
29
{
 
30
        int len = 0;
 
31
        int retval;
 
32
        unsigned int sta, en_mask, det_mask;
 
33
 
 
34
        retval = backend_display_get(io_op, &sta);
 
35
        if (retval < 0)
 
36
                return retval;
 
37
 
 
38
        for (en_mask = DISPLAY_LCD_ON; en_mask <= DISPLAY_DVI_ON; en_mask = en_mask << 1) {
 
39
                det_mask = en_mask << 4;        /* see display masks in omnibook.h */
 
40
                if (!(retval & en_mask) && !(retval & det_mask))
 
41
                        continue;       /* not supported */
 
42
                len += sprintf(buffer + len, "%s:", display_name[ffs(en_mask) - 1]);
 
43
                if (retval & det_mask)
 
44
                        len +=
 
45
                            sprintf(buffer + len, " display %s",
 
46
                                    (sta & det_mask) ? "present" : "absent");
 
47
                if (retval & en_mask)
 
48
                        len +=
 
49
                            sprintf(buffer + len, " port %s",
 
50
                                    (sta & en_mask) ? "enabled" : "disabled");
 
51
                len += sprintf(buffer + len, "\n");
 
52
        }
 
53
 
 
54
        return len;
 
55
}
 
56
 
 
57
static int omnibook_display_write(char *buffer, struct omnibook_operation *io_op)
 
58
{
 
59
        int retval;
 
60
        unsigned int state;
 
61
        char *endp;
 
62
 
 
63
        state = simple_strtoul(buffer, &endp, 16);
 
64
        if (endp == buffer)
 
65
                return -EINVAL;
 
66
        else
 
67
                retval = backend_display_set(io_op, state);
 
68
 
 
69
        return retval;
 
70
}
 
71
 
 
72
static struct omnibook_feature display_driver;
 
73
 
 
74
static int __init omnibook_display_init(struct omnibook_operation *io_op)
 
75
{
 
76
        int retval;
 
77
        unsigned int state;
 
78
        
 
79
        /* Disable file writing if unsuported by backend */
 
80
        if (!io_op->backend->display_set)
 
81
                display_driver.write = NULL;
 
82
                
 
83
        retval = backend_display_get(io_op, &state);
 
84
        if (retval < 0)
 
85
                return retval;
 
86
        else
 
87
                return 0;
 
88
}
 
89
 
 
90
static struct omnibook_tbl display_table[] __initdata = {
 
91
        {TSM70 | TSX205, {ACPI,}},
 
92
        {TSM40, {SMI, SMI_GET_DISPLAY_STATE, SMI_SET_DISPLAY_STATE, 0, 0, 0}},
 
93
        {XE3GF | TSP10 | TSM70 | TSM30X | TSM40, SIMPLE_BYTE(EC, XE3GF_STA1, XE3GF_SHDD_MASK)},
 
94
        {XE3GC, SIMPLE_BYTE(EC, XE3GC_STA1, XE3GC_CRTI_MASK)},
 
95
        {OB500 | OB510 | OB6000 | OB6100 | XE4500, SIMPLE_BYTE(EC, OB500_STA1, OB500_CRTS_MASK)},
 
96
        {OB4150, SIMPLE_BYTE(EC, OB4150_STA2, OB4150_CRST_MASK)},
 
97
        {0,}
 
98
};
 
99
 
 
100
static struct omnibook_feature __declared_feature display_driver = {
 
101
        .name = "display",
 
102
        .enabled = 1,
 
103
        .init = omnibook_display_init,
 
104
        .read = omnibook_display_read,
 
105
        .write = omnibook_display_write,
 
106
        .ectypes =
 
107
            XE3GF | XE3GC | OB500 | OB510 | OB6000 | OB6100 | XE4500 | OB4150 | TSP10 | TSM70 | TSM30X |
 
108
            TSM40 | TSX205,
 
109
        .tbl = display_table,
 
110
};
 
111
 
 
112
module_param_named(display, display_driver.enabled, int, S_IRUGO);
 
113
MODULE_PARM_DESC(display, "Use 0 to disable, 1 to enable display status handling");
 
114
/* End of file */