History

mfd: cros_ec: Add lightbar v2 API

New API split commands, improve EC command latency.

Gwendal Grignou committed 7 years ago

Commit de83db51 parent 89193a01 file · +120 −4Browse files

Unified · Split

include/linux/mfd/cros_ec_commands.h+120−4
@@ -1658,7 +1658,10 @@ struct lightbar_params_v1 { · 1657 unmodified lines
1658 int32_t s3_sleep_for;1658 int32_t s3_sleep_for;
1659 int32_t s3_ramp_up;1659 int32_t s3_ramp_up;
1660 int32_t s3_ramp_down;1660 int32_t s3_ramp_down;
1661 int32_t s5_ramp_up;
1662 int32_t s5_ramp_down;
1661 int32_t tap_tick_delay;1663 int32_t tap_tick_delay;
1664 int32_t tap_gate_delay;
1662 int32_t tap_display_time;1665 int32_t tap_display_time;
1663 1666
1664 /* Tap-for-battery params */1667 /* Tap-for-battery params */
@@ -1686,11 +1689,82 @@ struct lightbar_params_v1 { · 21 unmodified lines
1686 uint8_t s0_idx[2][LB_BATTERY_LEVELS]; /* AP is running */1689 uint8_t s0_idx[2][LB_BATTERY_LEVELS]; /* AP is running */
1687 uint8_t s3_idx[2][LB_BATTERY_LEVELS]; /* AP is sleeping */1690 uint8_t s3_idx[2][LB_BATTERY_LEVELS]; /* AP is sleeping */
1688 1691
1692 /* s5: single color pulse on inhibited power-up */
1693 uint8_t s5_idx;
1694
1689 /* Color palette */1695 /* Color palette */
1690 struct rgb_s color[8]; /* 0-3 are Google colors */1696 struct rgb_s color[8]; /* 0-3 are Google colors */
1691} __ec_todo_packed;1697} __ec_todo_packed;
1692 1698
1693/* Lightbar program */1699/* Lightbar command params v2
1700 * crbug.com/467716
1701 *
1702 * lightbar_parms_v1 was too big for i2c, therefore in v2, we split them up by
1703 * logical groups to make it more manageable ( < 120 bytes).
1704 *
1705 * NOTE: Each of these groups must be less than 120 bytes.
1706 */
1707
1708struct lightbar_params_v2_timing {
1709 /* Timing */
1710 int32_t google_ramp_up;
1711 int32_t google_ramp_down;
1712 int32_t s3s0_ramp_up;
1713 int32_t s0_tick_delay[2]; /* AC=0/1 */
1714 int32_t s0a_tick_delay[2]; /* AC=0/1 */
1715 int32_t s0s3_ramp_down;
1716 int32_t s3_sleep_for;
1717 int32_t s3_ramp_up;
1718 int32_t s3_ramp_down;
1719 int32_t s5_ramp_up;
1720 int32_t s5_ramp_down;
1721 int32_t tap_tick_delay;
1722 int32_t tap_gate_delay;
1723 int32_t tap_display_time;
1724} __ec_todo_packed;
1725
1726struct lightbar_params_v2_tap {
1727 /* Tap-for-battery params */
1728 uint8_t tap_pct_red;
1729 uint8_t tap_pct_green;
1730 uint8_t tap_seg_min_on;
1731 uint8_t tap_seg_max_on;
1732 uint8_t tap_seg_osc;
1733 uint8_t tap_idx[3];
1734} __ec_todo_packed;
1735
1736struct lightbar_params_v2_oscillation {
1737 /* Oscillation */
1738 uint8_t osc_min[2]; /* AC=0/1 */
1739 uint8_t osc_max[2]; /* AC=0/1 */
1740 uint8_t w_ofs[2]; /* AC=0/1 */
1741} __ec_todo_packed;
1742
1743struct lightbar_params_v2_brightness {
1744 /* Brightness limits based on the backlight and AC. */
1745 uint8_t bright_bl_off_fixed[2]; /* AC=0/1 */
1746 uint8_t bright_bl_on_min[2]; /* AC=0/1 */
1747 uint8_t bright_bl_on_max[2]; /* AC=0/1 */
1748} __ec_todo_packed;
1749
1750struct lightbar_params_v2_thresholds {
1751 /* Battery level thresholds */
1752 uint8_t battery_threshold[LB_BATTERY_LEVELS - 1];
1753} __ec_todo_packed;
1754
1755struct lightbar_params_v2_colors {
1756 /* Map [AC][battery_level] to color index */
1757 uint8_t s0_idx[2][LB_BATTERY_LEVELS]; /* AP is running */
1758 uint8_t s3_idx[2][LB_BATTERY_LEVELS]; /* AP is sleeping */
1759
1760 /* s5: single color pulse on inhibited power-up */
1761 uint8_t s5_idx;
1762
1763 /* Color palette */
1764 struct rgb_s color[8]; /* 0-3 are Google colors */
1765} __ec_todo_packed;
1766
1767/* Lightbar program. */
1694#define EC_LB_PROG_LEN 1921768#define EC_LB_PROG_LEN 192
1695struct lightbar_program {1769struct lightbar_program {
1696 uint8_t size;1770 uint8_t size;
@@ -1704,7 +1778,10 @@ struct ec_params_lightbar { · 7 unmodified lines
1704 * The following commands have no args:1778 * The following commands have no args:
1705 *1779 *
1706 * dump, off, on, init, get_seq, get_params_v0, get_params_v1,1780 * dump, off, on, init, get_seq, get_params_v0, get_params_v1,
1707 * version, get_brightness, get_demo, suspend, resume1781 * version, get_brightness, get_demo, suspend, resume,
1782 * get_params_v2_timing, get_params_v2_tap, get_params_v2_osc,
1783 * get_params_v2_bright, get_params_v2_thlds,
1784 * get_params_v2_colors
1708 *1785 *
1709 * Don't use an empty struct, because C++ hates that.1786 * Don't use an empty struct, because C++ hates that.
1710 */1787 */
@@ -1731,6 +1808,14 @@ struct ec_params_lightbar { · 20 unmodified lines
1731 1808
1732 struct lightbar_params_v0 set_params_v0;1809 struct lightbar_params_v0 set_params_v0;
1733 struct lightbar_params_v1 set_params_v1;1810 struct lightbar_params_v1 set_params_v1;
1811
1812 struct lightbar_params_v2_timing set_v2par_timing;
1813 struct lightbar_params_v2_tap set_v2par_tap;
1814 struct lightbar_params_v2_oscillation set_v2par_osc;
1815 struct lightbar_params_v2_brightness set_v2par_bright;
1816 struct lightbar_params_v2_thresholds set_v2par_thlds;
1817 struct lightbar_params_v2_colors set_v2par_colors;
1818
1734 struct lightbar_program set_program;1819 struct lightbar_program set_program;
1735 };1820 };
1736} __ec_todo_packed;1821} __ec_todo_packed;
@@ -1752,6 +1837,14 @@ struct ec_response_lightbar { · 15 unmodified lines
1752 struct lightbar_params_v0 get_params_v0;1837 struct lightbar_params_v0 get_params_v0;
1753 struct lightbar_params_v1 get_params_v1;1838 struct lightbar_params_v1 get_params_v1;
1754 1839
1840
1841 struct lightbar_params_v2_timing get_params_v2_timing;
1842 struct lightbar_params_v2_tap get_params_v2_tap;
1843 struct lightbar_params_v2_oscillation get_params_v2_osc;
1844 struct lightbar_params_v2_brightness get_params_v2_bright;
1845 struct lightbar_params_v2_thresholds get_params_v2_thlds;
1846 struct lightbar_params_v2_colors get_params_v2_colors;
1847
1755 struct __ec_todo_unpacked {1848 struct __ec_todo_unpacked {
1756 uint32_t num;1849 uint32_t num;
1757 uint32_t flags;1850 uint32_t flags;
@@ -1764,9 +1857,11 @@ struct ec_response_lightbar { · 6 unmodified lines
1764 /*1857 /*
1765 * The following commands have no response:1858 * The following commands have no response:
1766 *1859 *
1767 * off, on, init, set_brightness, seq, reg, set_rgb,1860 * off, on, init, set_brightness, seq, reg, set_rgb, demo,
1768 * set_params_v0, set_params_v1, set_program,1861 * set_params_v0, set_params_v1, set_program,
1769 * manual_suspend_ctrl, suspend, resume1862 * manual_suspend_ctrl, suspend, resume, set_v2par_timing,
1863 * set_v2par_tap, set_v2par_osc, set_v2par_bright,
1864 * set_v2par_thlds, set_v2par_colors
1770 */1865 */
1771 };1866 };
1772} __ec_todo_packed;1867} __ec_todo_packed;
@@ -1795,6 +1890,18 @@ enum lightbar_command { · 22 unmodified lines
1795 LIGHTBAR_CMD_MANUAL_SUSPEND_CTRL = 19,1890 LIGHTBAR_CMD_MANUAL_SUSPEND_CTRL = 19,
1796 LIGHTBAR_CMD_SUSPEND = 20,1891 LIGHTBAR_CMD_SUSPEND = 20,
1797 LIGHTBAR_CMD_RESUME = 21,1892 LIGHTBAR_CMD_RESUME = 21,
1893 LIGHTBAR_CMD_GET_PARAMS_V2_TIMING = 22,
1894 LIGHTBAR_CMD_SET_PARAMS_V2_TIMING = 23,
1895 LIGHTBAR_CMD_GET_PARAMS_V2_TAP = 24,
1896 LIGHTBAR_CMD_SET_PARAMS_V2_TAP = 25,
1897 LIGHTBAR_CMD_GET_PARAMS_V2_OSCILLATION = 26,
1898 LIGHTBAR_CMD_SET_PARAMS_V2_OSCILLATION = 27,
1899 LIGHTBAR_CMD_GET_PARAMS_V2_BRIGHTNESS = 28,
1900 LIGHTBAR_CMD_SET_PARAMS_V2_BRIGHTNESS = 29,
1901 LIGHTBAR_CMD_GET_PARAMS_V2_THRESHOLDS = 30,
1902 LIGHTBAR_CMD_SET_PARAMS_V2_THRESHOLDS = 31,
1903 LIGHTBAR_CMD_GET_PARAMS_V2_COLORS = 32,
1904 LIGHTBAR_CMD_SET_PARAMS_V2_COLORS = 33,
1798 LIGHTBAR_NUM_CMDS1905 LIGHTBAR_NUM_CMDS
1799};1906};
1800 1907
@@ -1813,6 +1920,14 @@ enum ec_led_id { · 12 unmodified lines
1813 EC_LED_ID_POWER_LED,1920 EC_LED_ID_POWER_LED,
1814 /* LED on power adapter or its plug */1921 /* LED on power adapter or its plug */
1815 EC_LED_ID_ADAPTER_LED,1922 EC_LED_ID_ADAPTER_LED,
1923 /* LED to indicate left side */
1924 EC_LED_ID_LEFT_LED,
1925 /* LED to indicate right side */
1926 EC_LED_ID_RIGHT_LED,
1927 /* LED to indicate recovery mode with HW_REINIT */
1928 EC_LED_ID_RECOVERY_HW_REINIT_LED,
1929 /* LED to indicate sysrq debug mode. */
1930 EC_LED_ID_SYSRQ_DEBUG_LED,
1816 1931
1817 EC_LED_ID_COUNT1932 EC_LED_ID_COUNT
1818};1933};
@@ -1827,6 +1942,7 @@ enum ec_led_colors { · 8 unmodified lines
1827 EC_LED_COLOR_BLUE,1942 EC_LED_COLOR_BLUE,
1828 EC_LED_COLOR_YELLOW,1943 EC_LED_COLOR_YELLOW,
1829 EC_LED_COLOR_WHITE,1944 EC_LED_COLOR_WHITE,
1945 EC_LED_COLOR_AMBER,
1830 1946
1831 EC_LED_COLOR_COUNT1947 EC_LED_COLOR_COUNT
1832};1948};

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t