Fix 2720 hardware support and streamline changelog
This commit is contained in:
1 parent
3b96b8f242
commit
a4f2051d50
20 files changed
+115
-391
No files matched your search
@@ -14,6 +14,7 @@
|
||||
#define LOCK_FLAG "/tmp/bananarchy_screen_locked"
|
||||
#define LOCKER_FIFO "/tmp/dwm_plugin_locker.fifo"
|
||||
#define LID_STABLE_MS 80
|
||||
#define HALL_POLL_MS 200
|
||||
#define GPIO_FILE "/sys/kernel/debug/gpio"
|
||||
#define COVER_SOCKET "/run/bananarchy/cover.sock"
|
||||
#define LID_CLIENT_SOCKET "/run/bananarchy/lid-client.sock"
|
||||
@@ -250,6 +251,7 @@ int main(void)
|
||||
struct watch_list list;
|
||||
long long now;
|
||||
long long last_scan = 0;
|
||||
long long last_hall_poll = 0;
|
||||
long long last_transition = 0;
|
||||
long long last_broadcast = 0;
|
||||
long long candidate_since;
|
||||
@@ -263,12 +265,13 @@ int main(void)
|
||||
install_reaper();
|
||||
memset(&list, 0, sizeof(list));
|
||||
switch_mask = current_switch_mask(&evdev_found);
|
||||
if(evdev_found)
|
||||
hall = hall_state();
|
||||
if(hall >= 0)
|
||||
stable_closed = hall;
|
||||
else if(evdev_found)
|
||||
stable_closed = (switch_mask & (int)CLOSED_MASK) != 0;
|
||||
else {
|
||||
hall = hall_state();
|
||||
stable_closed = hall >= 0 ? hall : 0;
|
||||
}
|
||||
else
|
||||
stable_closed = 0;
|
||||
candidate = stable_closed;
|
||||
now = now_ms();
|
||||
candidate_since = now;
|
||||
@@ -300,12 +303,14 @@ int main(void)
|
||||
}
|
||||
if(nfds > 0)
|
||||
read_ready(&list, fds, nfds, &switch_mask);
|
||||
if(list.count > 0) {
|
||||
observed = (switch_mask & (int)CLOSED_MASK) != 0;
|
||||
} else {
|
||||
observed = (switch_mask & (int)CLOSED_MASK) != 0;
|
||||
/* EV_SW can miss edges or report a stale mask on the 2720 hall sensors.
|
||||
* Reconcile with the raw lines even while evdev remains available. */
|
||||
if(now - last_hall_poll >= HALL_POLL_MS) {
|
||||
hall = hall_state();
|
||||
observed = hall >= 0 ? hall :
|
||||
(switch_mask & (int)CLOSED_MASK) != 0;
|
||||
if(hall >= 0)
|
||||
observed = hall;
|
||||
last_hall_poll = now;
|
||||
}
|
||||
if(observed != candidate) {
|
||||
candidate = observed;
|
||||
|
||||
@@ -171,6 +171,7 @@ struct msm8905_cam_dev {
|
||||
u16 chip_id;
|
||||
bool streaming;
|
||||
bool hw_initialized;
|
||||
bool rotate_180;
|
||||
};
|
||||
|
||||
static struct msm8905_cam_dev *g_cam;
|
||||
@@ -600,17 +601,19 @@ static int msm8905_cam_hw_init(struct msm8905_cam_dev *cam)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void msm8905_cam_demosaic(const u8 *raw, u8 *rgb)
|
||||
static void msm8905_cam_demosaic(const u8 *raw, u8 *rgb, bool rotate_180)
|
||||
{
|
||||
u32 y, x;
|
||||
u32 idx = 0;
|
||||
|
||||
for (y = 0; y < CAM_OUT_HEIGHT; y++) {
|
||||
const u8 *r0 = raw + (2U * y) * CAM_RAW_STRIDE;
|
||||
const u8 *r1 = raw + (2U * y + 1U) * CAM_RAW_STRIDE;
|
||||
u32 src_y = rotate_180 ? CAM_OUT_HEIGHT - 1U - y : y;
|
||||
const u8 *r0 = raw + (2U * src_y) * CAM_RAW_STRIDE;
|
||||
const u8 *r1 = raw + (2U * src_y + 1U) * CAM_RAW_STRIDE;
|
||||
|
||||
for (x = 0; x < CAM_OUT_WIDTH; x += 2U) {
|
||||
u32 g_off = (x >> 1) * 5U;
|
||||
u32 src_x = rotate_180 ? CAM_OUT_WIDTH - 2U - x : x;
|
||||
u32 g_off = (src_x >> 1) * 5U;
|
||||
u8 b0 = r0[g_off + 0U];
|
||||
u8 g0 = (u8)(((u32)r0[g_off + 1U] + (u32)r1[g_off + 0U]) >> 1);
|
||||
u8 r_0 = r1[g_off + 1U];
|
||||
@@ -618,12 +621,21 @@ static void msm8905_cam_demosaic(const u8 *raw, u8 *rgb)
|
||||
u8 g1 = (u8)(((u32)r0[g_off + 3U] + (u32)r1[g_off + 2U]) >> 1);
|
||||
u8 r_1 = r1[g_off + 3U];
|
||||
|
||||
rgb[idx + 0U] = r_0;
|
||||
rgb[idx + 1U] = g0;
|
||||
rgb[idx + 2U] = b0;
|
||||
rgb[idx + 3U] = r_1;
|
||||
rgb[idx + 4U] = g1;
|
||||
rgb[idx + 5U] = b1;
|
||||
if (rotate_180) {
|
||||
rgb[idx + 0U] = r_1;
|
||||
rgb[idx + 1U] = g1;
|
||||
rgb[idx + 2U] = b1;
|
||||
rgb[idx + 3U] = r_0;
|
||||
rgb[idx + 4U] = g0;
|
||||
rgb[idx + 5U] = b0;
|
||||
} else {
|
||||
rgb[idx + 0U] = r_0;
|
||||
rgb[idx + 1U] = g0;
|
||||
rgb[idx + 2U] = b0;
|
||||
rgb[idx + 3U] = r_1;
|
||||
rgb[idx + 4U] = g1;
|
||||
rgb[idx + 5U] = b1;
|
||||
}
|
||||
idx += 6U;
|
||||
}
|
||||
}
|
||||
@@ -723,7 +735,7 @@ static int msm8905_cam_capture_rgb(struct msm8905_cam_dev *cam, u8 *dst_rgb)
|
||||
return -ETIMEDOUT;
|
||||
}
|
||||
|
||||
msm8905_cam_demosaic(cam->raw_dma_buf, dst_rgb);
|
||||
msm8905_cam_demosaic(cam->raw_dma_buf, dst_rgb, cam->rotate_180);
|
||||
cam->sequence++;
|
||||
return 0;
|
||||
}
|
||||
@@ -1105,6 +1117,8 @@ static int __init msm8905_cam_init(void)
|
||||
return -ENOMEM;
|
||||
|
||||
mutex_init(&cam->lock);
|
||||
/* The 2720 Flip sensor is mounted 180 degrees from the other Nokia targets. */
|
||||
cam->rotate_180 = of_machine_is_compatible("nokia,beatles");
|
||||
|
||||
cam->pdev = platform_device_register_simple("msm8905-cam", -1, NULL, 0);
|
||||
if (IS_ERR(cam->pdev)) {
|
||||
@@ -1160,8 +1174,8 @@ static int __init msm8905_cam_init(void)
|
||||
goto err_v4l2;
|
||||
|
||||
g_cam = cam;
|
||||
pr_info("msm8905-cam: registered /dev/video%d (GC2395/GC2385 800x600 RGB24, dma=0x%08llx)\n",
|
||||
cam->vdev.num, (unsigned long long)cam->raw_dma_phys);
|
||||
pr_info("msm8905-cam: registered /dev/video%d (GC2395/GC2385 800x600 RGB24, dma=0x%08llx, rotate180=%u)\n",
|
||||
cam->vdev.num, (unsigned long long)cam->raw_dma_phys, cam->rotate_180);
|
||||
return 0;
|
||||
|
||||
err_v4l2:
|
||||
|
||||
Reference in new issue
Block a user