mirror of
https://github.com/linux-msm/cdba.git
synced 2026-02-25 13:11:56 -08:00
Add special keys to allow triggering power and fastboot key presses from the cdba client. There is an option to send a short key "pulse" (press followed by release after 100ms) or to press/release keys separately: - ctrl+a -> o: Send power key pulse - ctrl+a -> O: Toggle power key (first use: press, next use: release) - ctrl+a -> f: Send fastboot key pulse - ctrl+a -> F: Toggle fastboot key (first use: press, next use: release) In most cases you want to send the "pulse" (short key press), so it's helpful to have this mapped to a single key. This avoids forgetting to release the key again after pressing it. The protocol between CDBA client and server is: (MSG_KEY_PRESS <key:u8, state:u8>) where key is either DEVICE_KEY_FASTBOOT (0) or DEVICE_KEY_POWER (1) and state is either KEY_PRESS_RELEASE (0), KEY_PRESS_PRESS (1) or KEY_PRESS_PULSE (2). The reason for implementing the "pulse" on the server side is that it's hard to guarantee the timing on the client side. We don't know exactly when the packets will arrive on the server. Also, "state" is a full byte anyway, so might as well use some of the extra bits. :-)
111 lines
2.8 KiB
C
111 lines
2.8 KiB
C
#ifndef __DEVICE_H__
|
|
#define __DEVICE_H__
|
|
|
|
#include <termios.h>
|
|
#include "cdba.h"
|
|
#include "list.h"
|
|
|
|
struct cdb_assist;
|
|
struct fastboot;
|
|
struct fastboot_ops;
|
|
struct device;
|
|
struct device_parser;
|
|
|
|
struct control_ops {
|
|
void *(*parse_options)(struct device_parser *dp);
|
|
void *(*open)(struct device *dev);
|
|
void (*close)(struct device *dev);
|
|
int (*power)(struct device *dev, bool on);
|
|
void (*usb)(struct device *dev, bool on);
|
|
void (*key)(struct device *device, int key, bool asserted);
|
|
void (*status_enable)(struct device *dev);
|
|
};
|
|
|
|
struct console_ops {
|
|
void *(*open)(struct device *dev);
|
|
int (*write)(struct device *dev, const void *buf, size_t len);
|
|
|
|
void (*send_break)(struct device *dev);
|
|
};
|
|
|
|
struct device {
|
|
char *board;
|
|
char *control_dev;
|
|
void *control_options;
|
|
char *console_dev;
|
|
char *name;
|
|
char *serial;
|
|
char *description;
|
|
char *ppps_path;
|
|
char *ppps3_path;
|
|
struct list_head *users;
|
|
unsigned voltage;
|
|
bool tickle_mmc;
|
|
bool usb_always_on;
|
|
bool power_always_on;
|
|
struct fastboot *fastboot;
|
|
unsigned int fastboot_key_timeout;
|
|
int state;
|
|
bool has_power_key;
|
|
|
|
bool status_enabled;
|
|
|
|
void (*boot)(struct device *);
|
|
|
|
const struct control_ops *control_ops;
|
|
const struct console_ops *console_ops;
|
|
|
|
const char *set_active;
|
|
|
|
void *cdb;
|
|
void *console;
|
|
|
|
char *status_cmd;
|
|
|
|
struct list_head node;
|
|
};
|
|
|
|
struct device_user {
|
|
const char *username;
|
|
|
|
struct list_head node;
|
|
};
|
|
|
|
void device_add(struct device *device);
|
|
|
|
struct device *device_open(const char *board,
|
|
const char *username);
|
|
void device_close(struct device *dev);
|
|
int device_power(struct device *device, bool on);
|
|
void device_key(struct device *device, int key, bool asserted);
|
|
|
|
void device_status_enable(struct device *device);
|
|
void device_usb(struct device *device, bool on);
|
|
int device_write(struct device *device, const void *buf, size_t len);
|
|
|
|
void device_boot(struct device *device, const void *data, size_t len);
|
|
|
|
void device_fastboot_open(struct device *device,
|
|
struct fastboot_ops *fastboot_ops);
|
|
void device_fastboot_boot(struct device *device);
|
|
void device_fastboot_flash_reboot(struct device *device);
|
|
void device_send_break(struct device *device);
|
|
void device_list_devices(const char *username);
|
|
void device_info(const char *username, const void *data, size_t dlen);
|
|
void device_fastboot_continue(struct device *device);
|
|
bool device_is_running(struct device *device);
|
|
|
|
extern const struct control_ops alpaca_ops;
|
|
extern const struct control_ops cdb_assist_ops;
|
|
extern const struct control_ops conmux_ops;
|
|
extern const struct control_ops ftdi_gpio_ops;
|
|
extern const struct control_ops local_gpio_ops;
|
|
extern const struct control_ops external_ops;
|
|
extern const struct control_ops qcomlt_dbg_ops;
|
|
extern const struct control_ops laurent_ops;
|
|
|
|
extern const struct console_ops conmux_console_ops;
|
|
extern const struct console_ops console_ops;
|
|
|
|
#endif
|