return sysfs_emit(buf, "%d %d\n", version, flags);
}
+static ssize_t num_segments_show(struct device *dev,
+ struct device_attribute *attr, char *buf)
+{
+ struct ec_params_lightbar *param;
+ struct ec_response_lightbar *resp;
+ struct cros_ec_command *msg;
+ struct cros_ec_dev *ec = to_cros_ec_dev(dev);
+ uint32_t num = 0;
+ int ret;
+
+ ret = lb_throttle();
+ if (ret)
+ return ret;
+
+ msg = alloc_lightbar_cmd_msg(ec);
+ if (!msg)
+ return -ENOMEM;
+
+ param = (struct ec_params_lightbar *)msg->data;
+ param->cmd = LIGHTBAR_CMD_GET_PARAMS_V3;
+ msg->outsize = sizeof(param->cmd);
+ msg->insize = sizeof(resp->get_params_v3);
+ ret = cros_ec_cmd_xfer_status(ec->ec_dev, msg);
+ if (ret < 0 && ret != -EINVAL)
+ goto exit;
+
+ if (msg->result == EC_RES_SUCCESS) {
+ resp = (struct ec_response_lightbar *)msg->data;
+ num = resp->get_params_v3.reported_led_num;
+ }
+
+ /*
+ * Anything else (ie, EC_RES_INVALID_COMMAND) - no direct control over
+ * LEDs, return that no leds are supported.
+ */
+ ret = sysfs_emit(buf, "%u\n", num);
+exit:
+ kfree(msg);
+ return ret;
+}
+
static ssize_t brightness_store(struct device *dev,
struct device_attribute *attr,
const char *buf, size_t count)
/* Module initialization */
static DEVICE_ATTR_RW(interval_msec);
+static DEVICE_ATTR_RO(num_segments);
static DEVICE_ATTR_RO(version);
static DEVICE_ATTR_WO(brightness);
static DEVICE_ATTR_WO(led_rgb);
static struct attribute *__lb_cmds_attrs[] = {
&dev_attr_interval_msec.attr,
+ &dev_attr_num_segments.attr,
&dev_attr_version.attr,
&dev_attr_brightness.attr,
&dev_attr_led_rgb.attr,
struct rgb_s color[8]; /* 0-3 are Google colors */
} __ec_todo_packed;
+struct lightbar_params_v3 {
+ /*
+ * Number of LEDs reported by the EC.
+ * May be less than the actual number of LEDs in the lightbar.
+ */
+ uint8_t reported_led_num;
+} __ec_todo_packed;
+
/* Lightbar program. */
#define EC_LB_PROG_LEN 192
struct lightbar_program {
struct lightbar_params_v2_thresholds get_params_v2_thlds;
struct lightbar_params_v2_colors get_params_v2_colors;
+ struct lightbar_params_v3 get_params_v3;
+
struct __ec_todo_unpacked {
uint32_t num;
uint32_t flags;
LIGHTBAR_CMD_SET_PARAMS_V2_THRESHOLDS = 31,
LIGHTBAR_CMD_GET_PARAMS_V2_COLORS = 32,
LIGHTBAR_CMD_SET_PARAMS_V2_COLORS = 33,
+ LIGHTBAR_CMD_GET_PARAMS_V3 = 34,
LIGHTBAR_NUM_CMDS
};