~ubuntu-branches/ubuntu/edgy/fnfx/edgy

« back to all changes in this revision

Viewing changes to src/fnfx.h

  • Committer: Bazaar Package Importer
  • Author(s): Thom May
  • Date: 2005-04-01 11:39:55 UTC
  • Revision ID: james.westby@ubuntu.com-20050401113955-nnsv7bovk07obxa9
Tags: upstream-0.3
ImportĀ upstreamĀ versionĀ 0.3

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Author: Timo Hoenig <thoenig@nouse.net>
 
3
 * Copyright (c) 2003, 2004 Timo Hoenig <thoenig@nouse.net>
 
4
 *                          All rights reserved
 
5
 *
 
6
 * This program is free software; you can redistribute it and/or modify
 
7
 * it under the terms of the GNU General Public License as published by
 
8
 * the Free Software Foundation; either version 2, or (at your option)
 
9
 * any later version.
 
10
 *
 
11
 * This program is distributed in the hope that it will be useful,
 
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
14
 * GNU General Public License for more details.
 
15
 *
 
16
 * You should have received a copy of the GNU General Public License
 
17
 * along with this program; if not, write to the Free Software
 
18
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 
19
 *
 
20
 */
 
21
 
 
22
#include <sys/types.h>
 
23
#include <stddef.h>
 
24
#include <stdlib.h>
 
25
#include <unistd.h>
 
26
#include <stdio.h>
 
27
#include <stdarg.h>
 
28
#include <errno.h>
 
29
#include <math.h>
 
30
#include <string.h>
 
31
 
 
32
#include <signal.h>
 
33
 
 
34
#include <sys/ipc.h>
 
35
#include <sys/shm.h>
 
36
#include <sys/sem.h>
 
37
 
 
38
/* 
 
39
 * Defines
 
40
 * 
 
41
 */
 
42
 
 
43
#define DEBUG           0x1
 
44
#define NODETACH        0x2
 
45
#define OPT_ERROR       0x4
 
46
 
 
47
#define ACPI_TOSHIBA    "/proc/acpi/toshiba"
 
48
#define ACPI_FAN        "/proc/acpi/toshiba/fan"
 
49
#define ACPI_KEYS       "/proc/acpi/toshiba/keys"
 
50
#define ACPI_LCD        "/proc/acpi/toshiba/lcd"
 
51
#define ACPI_VERSION    "/proc/acpi/toshiba/version"
 
52
#define ACPI_VIDEO      "/proc/acpi/toshiba/video"
 
53
#define ACPI_SLEEP      "/proc/acpi/sleep"
 
54
#define ACPI_CPU        "/proc/acpi/processor/CPU0/limit"
 
55
#define ACPI_BLUETOOTH  "/proc/acpi/toshiba/bluetooth"
 
56
 
 
57
#define VAL_TOSHIBA     0x01
 
58
#define VAL_FAN         0x02
 
59
#define VAL_KEYS        0x04
 
60
#define VAL_LCD         0x08
 
61
#define VAL_VERSION     0x10
 
62
#define VAL_VIDEO       0x20
 
63
#define VAL_SLEEP       0x40
 
64
 
 
65
#define VIDEO_LCD       0x1
 
66
#define VIDEO_CRT       0x2
 
67
#define VIDEO_TV        0x4
 
68
 
 
69
#define FNKEY_ENABLED   0x1
 
70
#define FNKEY_CLIENT    0x2
 
71
#define FNKEY_EXTERNAL  0x4
 
72
 
 
73
#define MIXER_ENABLED   0x1
 
74
#define MIXER_MUTE      0x2
 
75
 
 
76
#define SHMKEY          0x31011980
 
77
#define SHMSIZE         655360
 
78
 
 
79
#define SEMKEY          0x31011980
 
80
 
 
81
#define MSGBUFSIZE      1024
 
82
#define LINE_SIZE       128
 
83
#define CMD_SIZE        128
 
84
#define MIXER_SIZE      128
 
85
 
 
86
#define DCFG_OFFSET     1024
 
87
#define CCFG_OFFSET     0
 
88
 
 
89
#define PIDFILE         "/var/run/fnfxd.pid"
 
90
 
 
91
typedef struct {
 
92
    int volume;
 
93
    int config;
 
94
    char device[MIXER_SIZE];
 
95
} s_mixer;
 
96
 
 
97
typedef struct {
 
98
    int value;
 
99
    int state;
 
100
 
 
101
    char command[CMD_SIZE];
 
102
    char client_command[CMD_SIZE];
 
103
    char descr[LINE_SIZE];
 
104
} s_fnkey;
 
105
 
 
106
typedef struct {
 
107
    int entries;
 
108
    s_fnkey fnkey[128];
 
109
} s_keymap;
 
110
 
 
111
typedef struct {
 
112
    int id;
 
113
    key_t key;
 
114
    struct sembuf op;
 
115
} s_sem_cfg;
 
116
 
 
117
typedef struct {
 
118
    int id;
 
119
    key_t key;
 
120
    void *addr;
 
121
} s_shmem_cfg;
 
122
 
 
123
typedef struct {
 
124
    int hotkey_ready;
 
125
    int hotkey;
 
126
 
 
127
    char *fnkey_descr;
 
128
    int fnkey_pos;
 
129
 
 
130
    int config;
 
131
    FILE *proc_fd;
 
132
} s_acpi_cfg;
 
133
 
 
134
/* FnFX Client Config */
 
135
typedef struct s_client_config {
 
136
    int flags;
 
137
 
 
138
    pid_t pid;
 
139
 
 
140
    s_shmem_cfg shmem;
 
141
    s_sem_cfg sem;
 
142
} t_client_cfg;
 
143
 
 
144
/* FnFX Daemon Config */
 
145
typedef struct s_daemon_config {
 
146
    int debug_flag;
 
147
    int nodetach_flag;
 
148
 
 
149
    pid_t pid;
 
150
    pid_t client_pid;
 
151
 
 
152
    s_shmem_cfg shmem;
 
153
    s_sem_cfg sem;
 
154
    s_acpi_cfg acpi;
 
155
    s_keymap keymap;
 
156
    s_mixer mixer;
 
157
} t_daemon_cfg;