Android-x86
Fork
捐款

  • R/O
  • HTTP
  • SSH
  • HTTPS

device-viliv-s5: 提交

device/viliv/s5


Commit MetaInfo

修訂0730150a6f88e0abadaf5a5513c85afcd2c5c711 (tree)
時間2010-08-17 16:33:25
作者Owen Kwon <pinebud77@hotm...>
CommiterOwen Kwon

Log Message

removed liblights

Change Summary

  • delete: liblights/Android.mk
  • delete: liblights/lights.c

差異

--- a/liblights/Android.mk
+++ /dev/null
@@ -1,31 +0,0 @@
1-# Copyright (C) 2009 The Android-x86 Open Source Project
2-#
3-# Licensed under the Apache License, Version 2.0 (the "License");
4-# you may not use this file except in compliance with the License.
5-# You may obtain a copy of the License at
6-#
7-# http://www.apache.org/licenses/LICENSE-2.0
8-#
9-# Unless required by applicable law or agreed to in writing, software
10-# distributed under the License is distributed on an "AS IS" BASIS,
11-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12-# See the License for the specific language governing permissions and
13-# limitations under the License.
14-
15-ifeq ($(TARGET_PRODUCT),s5)
16-LOCAL_PATH:= $(call my-dir)
17-# HAL module implemenation, not prelinked and stored in
18-# hw/<COPYPIX_HARDWARE_MODULE_ID>.<ro.board.platform>.so
19-include $(CLEAR_VARS)
20-
21-LOCAL_SRC_FILES := lights.c
22-
23-LOCAL_PRELINK_MODULE := false
24-LOCAL_MODULE_PATH := $(TARGET_OUT_SHARED_LIBRARIES)/hw
25-
26-LOCAL_SHARED_LIBRARIES := liblog
27-
28-LOCAL_MODULE := lights.s5
29-
30-include $(BUILD_SHARED_LIBRARY)
31-endif
--- a/liblights/lights.c
+++ /dev/null
@@ -1,280 +0,0 @@
1-/*
2- * Copyright (C) 2009 The Android-x86 Open Source Project
3- *
4- * Licensed under the Apache License, Version 2.0 (the "License");
5- * you may not use this file except in compliance with the License.
6- * You may obtain a copy of the License at
7- *
8- * http://www.apache.org/licenses/LICENSE-2.0
9- *
10- * Unless required by applicable law or agreed to in writing, software
11- * distributed under the License is distributed on an "AS IS" BASIS,
12- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13- * See the License for the specific language governing permissions and
14- * limitations under the License.
15- */
16-
17-
18-#define LOG_TAG "lights"
19-
20-#include <cutils/log.h>
21-
22-#include <stdint.h>
23-#include <string.h>
24-#include <unistd.h>
25-#include <errno.h>
26-#include <fcntl.h>
27-#include <pthread.h>
28-
29-#include <sys/ioctl.h>
30-#include <sys/types.h>
31-
32-#include <hardware/lights.h>
33-
34-/******************************************************************************/
35-
36-static pthread_once_t g_init = PTHREAD_ONCE_INIT;
37-static pthread_mutex_t g_lock = PTHREAD_MUTEX_INITIALIZER;
38-static int g_haveTrackballLight = 0;
39-static struct light_state_t g_notification;
40-static struct light_state_t g_battery;
41-static int g_backlight = 255;
42-static int g_trackball = -1;
43-static int g_buttons = 0;
44-static int g_attention = 0;
45-
46-/**
47- * device methods
48- */
49-
50-void init_globals(void)
51-{
52- // init the mutex
53- pthread_mutex_init(&g_lock, NULL);
54-}
55-
56-static int
57-write_int(char const* path, int value)
58-{
59- int fd;
60- static int already_warned = 0;
61-
62- fd = open(path, O_RDWR);
63- if (fd >= 0) {
64- char buffer[50];
65- int bytes = sprintf(buffer, "%d\n", value);
66- int amt = write(fd, buffer, bytes);
67- close(fd);
68- return amt == -1 ? -errno : 0;
69- } else {
70- if (already_warned == 0) {
71- LOGE("write_int failed to open %s\n", path);
72- already_warned = 1;
73- }
74- return -errno;
75- }
76-}
77-
78-static int
79-is_lit(struct light_state_t const* state)
80-{
81- return state->color & 0x00ffffff;
82-}
83-
84-static int
85-rgb_to_brightness(struct light_state_t const* state)
86-{
87- int color = state->color & 0x00ffffff;
88- return ((77*((color>>16)&0x00ff))
89- + (150*((color>>8)&0x00ff)) + (29*(color&0x00ff))) >> 8;
90-}
91-
92-static int
93-set_light_backlight(struct light_device_t* dev,
94- struct light_state_t const* state)
95-{
96- int err = 0;
97- int brightness = rgb_to_brightness(state); // brightness range: 0 - 255
98- pthread_mutex_lock(&g_lock);
99- g_backlight = brightness;
100- err = write_int("/sys/class/backlight/vilivs5-bl/brightness", brightness>>4); // eeepc brightness range: 0 - 15
101- LOGI("set_light_backlight brightness=%d, brightness>>4 = %d\n", brightness, brightness>>4);
102- if (g_haveTrackballLight) {
103- handle_trackball_light_locked(dev);
104- }
105- pthread_mutex_unlock(&g_lock);
106- return err;
107-}
108-
109-static int
110-set_light_keyboard(struct light_device_t* dev,
111- struct light_state_t const* state)
112-{
113- int err = 0;
114- /*
115- int on = is_lit(state);
116- pthread_mutex_lock(&g_lock);
117- err = write_int("/sys/class/leds/keyboard-backlight/brightness", on?255:0);
118- pthread_mutex_unlock(&g_lock);
119- */
120- return err;
121-}
122-
123-static int
124-set_light_buttons(struct light_device_t* dev,
125- struct light_state_t const* state)
126-{
127- int err = 0;
128- /*
129- int on = is_lit(state);
130- pthread_mutex_lock(&g_lock);
131- g_buttons = on;
132- err = write_int("/sys/class/leds/button-backlight/brightness", on?255:0);
133- pthread_mutex_unlock(&g_lock);
134- */
135- return err;
136-}
137-
138-static void
139-handle_speaker_battery_locked(struct light_device_t* dev)
140-{
141- /*
142- if (is_lit(&g_battery)) {
143- set_speaker_light_locked(dev, &g_battery);
144- } else {
145- set_speaker_light_locked(dev, &g_notification);
146- }
147- */
148-}
149-
150-static int
151-set_light_battery(struct light_device_t* dev,
152- struct light_state_t const* state)
153-{
154- /*
155- pthread_mutex_lock(&g_lock);
156- g_battery = *state;
157- if (g_haveTrackballLight) {
158- set_speaker_light_locked(dev, state);
159- }
160- handle_speaker_battery_locked(dev);
161- pthread_mutex_unlock(&g_lock);
162- */
163- return 0;
164-}
165-
166-static int
167-set_light_notifications(struct light_device_t* dev,
168- struct light_state_t const* state)
169-{
170- /*
171- pthread_mutex_lock(&g_lock);
172- g_notification = *state;
173- LOGV("set_light_notifications g_trackball=%d color=0x%08x",
174- g_trackball, state->color);
175- if (g_haveTrackballLight) {
176- handle_trackball_light_locked(dev);
177- }
178- handle_speaker_battery_locked(dev);
179- pthread_mutex_unlock(&g_lock);
180- */
181- return 0;
182-}
183-
184-static int
185-set_light_attention(struct light_device_t* dev,
186- struct light_state_t const* state)
187-{
188- /*
189- pthread_mutex_lock(&g_lock);
190- g_notification = *state;
191- LOGV("set_light_attention g_trackball=%d color=0x%08x",
192- g_trackball, state->color);
193- g_attention = rgb_to_brightness(state);
194- if (g_haveTrackballLight) {
195- handle_trackball_light_locked(dev);
196- }
197- pthread_mutex_unlock(&g_lock);
198- */
199- return 0;
200-}
201-
202-
203-/** Close the lights device */
204-static int
205-close_lights(struct light_device_t *dev)
206-{
207- if (dev) {
208- free(dev);
209- }
210- return 0;
211-}
212-
213-
214-/******************************************************************************/
215-
216-/**
217- * module methods
218- */
219-
220-/** Open a new instance of a lights device using name */
221-static int open_lights(const struct hw_module_t* module, char const* name,
222- struct hw_device_t** device)
223-{
224- int (*set_light)(struct light_device_t* dev,
225- struct light_state_t const* state);
226-
227- if (0 == strcmp(LIGHT_ID_BACKLIGHT, name)) {
228- set_light = set_light_backlight;
229- }
230- else if (0 == strcmp(LIGHT_ID_KEYBOARD, name)) {
231- set_light = set_light_keyboard;
232- }
233- else if (0 == strcmp(LIGHT_ID_BUTTONS, name)) {
234- set_light = set_light_buttons;
235- }
236- else if (0 == strcmp(LIGHT_ID_BATTERY, name)) {
237- set_light = set_light_battery;
238- }
239- else if (0 == strcmp(LIGHT_ID_NOTIFICATIONS, name)) {
240- set_light = set_light_notifications;
241- }
242- else if (0 == strcmp(LIGHT_ID_ATTENTION, name)) {
243- set_light = set_light_attention;
244- }
245- else {
246- return -EINVAL;
247- }
248-
249- pthread_once(&g_init, init_globals);
250-
251- struct light_device_t *dev = malloc(sizeof(struct light_device_t));
252- memset(dev, 0, sizeof(*dev));
253-
254- dev->common.tag = HARDWARE_DEVICE_TAG;
255- dev->common.version = 0;
256- dev->common.module = (struct hw_module_t*)module;
257- dev->common.close = (int (*)(struct hw_device_t*))close_lights;
258- dev->set_light = set_light;
259-
260- *device = (struct hw_device_t*)dev;
261- return 0;
262-}
263-
264-
265-static struct hw_module_methods_t lights_module_methods = {
266- .open = open_lights,
267-};
268-
269-/*
270- * The lights Module
271- */
272-const struct hw_module_t HAL_MODULE_INFO_SYM = {
273- .tag = HARDWARE_MODULE_TAG,
274- .version_major = 1,
275- .version_minor = 0,
276- .id = LIGHTS_HARDWARE_MODULE_ID,
277- .name = "S5 lights Module",
278- .author = "kelly2.blue@gmail.com",
279- .methods = &lights_module_methods,
280-};
Show on old repository browser