summaryrefslogtreecommitdiff
path: root/util/lbplay.c
Commit message (Collapse)AuthorAgeFilesLines
* Fix some stupid.stabilize-5511.Bstabilize-5500.71.Bstabilize-5500.26.Bstabilize-5500.130.Bstabilize-5500.100.Brelease-R34-5500.BBill Richardson2014-02-171-1/+1
| | | | | | | | | | | | | | Off-by-one error in read() call. BUG=chromium:239205 BRANCH=none TEST=none Change-Id: Ifec3dacfa07e83d70b2582036cab0cfc1ee9e8f7 Signed-off-by: Bill Richardson <wfrichar@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/186738 Reviewed-by: Dave Parker <dparker@chromium.org> Reviewed-by: Randall Spangler <rspangler@chromium.org>
* Update util/lbplay.c to use the sysfs interface.Bill Richardson2014-02-151-171/+138
| | | | | | | | | | | | | | | | | | | | | | | | This is just an example, demonstrating how a userspace program can access and control the Pixel lighbar. This change reflects the new unprivileged access methods. You can run this program to drive the lightbar without being root. BUG=chromium:239205 BRANCH=none TEST=manual Nothing builds this by default, but you can test it with cd src/platform/ec gcc -static util/lbplay.c then copy a.out to your Pixel and run it (from /tmp, since other directories are mounted noexec). Change-Id: I7c07512087c924d16c1c03df6176fba995fcd4f4 Signed-off-by: Bill Richardson <wfrichar@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/186672 Reviewed-by: Alec Berg <alecaberg@chromium.org>
* Add LIGHTBAR_CMD_VERSION command to detect lightbar features.stabilize-4636.BBill Richardson2013-08-301-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Most systems don't have a lightbar. Those that do need a way to detect that one exists. That's easily done by just sending a EC_CMD_LIGHTBAR_CMD command to the EC and checking the result. If the response is EC_RES_INVALID_COMMAND, there isn't a lightbar. But what .cmd value should we use in struct ec_params_lightbar? Future lightbar implementations (if any), could remove existing functions or add new ones, so there isn't a safe choice. This change adds a LIGHTBAR_CMD_VERSION operation to determine if any new implementation exists. Future systems should return some useful information in response to this command. Existing systems will return EC_RES_INVALID_PARAM, which is enough to distinguish them. BUG=chromium:239205 BRANCH=none TEST=manual make BOARD=link make BOARD=link runtests There are no user-visible changes in functionality to anything. Change-Id: Ibe37f74a4dcbf68dd6bfd1963530aec907e67534 Signed-off-by: Bill Richardson <wfrichar@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/167549 Reviewed-by: Randall Spangler <rspangler@chromium.org>
* Improved the BUILD_ASSERT macro to work outside of functions.Bill Richardson2013-04-291-4/+1
| | | | | | | | | | | | | | | | | | This will let us check the size of static array initializers. Also moved this macro definition and ARRAY_SIZE into a new "tricks.h" header, so that userspace utils can use it too. BUG=none BRANCH=none TEST=manual Built everything, tested on Link. Tried various assertions. Change-Id: I612891108ea37dbca3572e0f25ab54a7bc0ed860 Signed-off-by: Bill Richardson <wfrichar@chromium.org> Reviewed-on: https://gerrit.chromium.org/gerrit/49417 Reviewed-by: Randall Spangler <rspangler@chromium.org>
* Update lbplay.c with correct cooperative locking.Bill Richardson2013-03-131-6/+28
| | | | | | | | | | | | | | | | | | | | | | | | BUG=none BRANCH=none TEST=manual Build it manually, copy lbplay to DUT, run lbplay & ectool simultaneously. cd /mnt/stateful_partition mount -o remount,exec . scp USER@SOMEWHERE:/SOME/PATH/TO/lbplay . ./lbplay & ectool lightbar params ectool lightbar params ectool lightbar params The lbplay program should cause the lightbar to slowly ramp up to green and down to red. Meanwhile, the ectool command should work and not hang. Change-Id: I4f26b0530ceaacbc18f8b9f38d7cbdfdabf78015 Signed-off-by: Bill Richardson <wfrichar@chromium.org> Reviewed-on: https://gerrit.chromium.org/gerrit/45257 Reviewed-by: Mike Frysinger <vapier@chromium.org>
* Parameterize the lightbar behavior as much as possible.Bill Richardson2012-10-111-1/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This change replaces most of the hard-coded lightbar constants with values that can be updated at run-time, so that if we change our minds about colors and timing we can tweak some of the values without requiring an EC/BIOS update. It also adds the "ectool lightbar params" command to get and set those values from the host. You can see the values from the EC console ("lightbar params"), but there's no way to set them. BUG=chrome-os-partner:8039 BRANCH=Link TEST=manual From the EC console, run lightbar params It should display the current values that can be changed. Log in to the host and run this to see the same values: ectool lightbar params Or edit and change them with this: ectool lightbar params > /tmp/vals.txt vi /tmp/vals.txt ectool lightbar params /tmp/vals.txt The updated parameters are persistent across EC jumps (RO->RW), but are lost when/if the EC reboots (as it will after the AP is off for 24 hours, for example). Change-Id: Ic2a3fd6f8062673432b48904933e0c7239b8658b Signed-off-by: Bill Richardson <wfrichar@chromium.org> Reviewed-on: https://gerrit.chromium.org/gerrit/35289 Reviewed-by: Randall Spangler <rspangler@chromium.org>
* Refactor lightbar host command to pass messages the new way.Bill Richardson2012-09-211-55/+56
| | | | | | | | | | | | | | | | | | | | | | | | | | | We recently changed the way host messages are passed to the EC to make it work nicer across I2C. When we did, we updated all the internal structs except those used for lightbar commands. This CL updates the lightbar commands too. BUG=chrome-os-partner:11277 BRANCH=all TEST=manual This shouldn't change anything, but you can ensure that by poking at the lightbar manually. On Link, run this from a root shell: ectool lightbar seq stop ectool lightbar 4 ff 00 ff ectool lightbar seq run With the first command, the lightbar pattern should freeze. With the second command, it should turn magenta. With the third command, it should resume pulsing as before. Change-Id: Ic5dc4c827b3b4459288d7d9bd7d06af8a5176b3c Signed-off-by: Bill Richardson <wfrichar@chromium.org> Reviewed-on: https://gerrit.chromium.org/gerrit/33798 Reviewed-by: Randall Spangler <rspangler@chromium.org>
* Add "lightbar demo" mode for executive bikesheddingBill Richardson2012-08-201-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | I keep getting asked to build an EC image to manually control the lightbar patterns so that the Powers That Be can look at it. This change just makes it possible to turn that mode on and off for yourself. You'll need a root shell or the EC console to do it, though. BUG=chrome-os-partner:8039 BRANCH=link TEST=manual From the EC console, type lightbar demo 1 OR from the root shell run ectool lightbar demo 1 After that, these keys should change the lightbar appearance (transitions may be slow and subtle - that's intended): UP = battery is more fully charged DOWN = battery is less fully charged RIGHT = battery is charging LEFT = battery is discharging BRIGHT = increase lightbar brightness DIM = decrase lightbar brightness Note that this does not interfere with the normal function of any keys. It only adds some additional EC behavior. Change-Id: Ia1a9855188244d74b670f9dbfdf60e3ac0343460 Signed-off-by: Bill Richardson <wfrichar@chromium.org> Reviewed-on: https://gerrit.chromium.org/gerrit/30899
* Support new-style LPC command interface in EC, ectoolRandall Spangler2012-07-121-6/+6
| | | | | | | | | | | | | | | | | | Both EC and ectool are still backwards-compatible to the old interface. BUG=chrome-os-partner:11275 TEST=manual From U-boot prompt: mkbp hash // test old host talking to new EC From root shell: ectool echash // test new host talking to new EC You can also update just the OS and use an old EC, and verify that 'ectool echash' still works, which tests a new host talking to an old EC. Change-Id: I2afbb208cb16836f842ba119b74b1ab6a38ce5d5 Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://gerrit.chromium.org/gerrit/27313
* Tidy util headers and make ec_commands.h not include other headersRandall Spangler2012-06-291-1/+0
| | | | | | | | | | | | | In preparation for being able to copy ec_commands.h to u-boot, which is itself in preparation for u-boot picking it up from /usr/src/ec/ BUG=none TEST=make link, snow, bds Change-Id: If256434b6722ff0787ce21a8ed4c7035c28024a8 Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://gerrit.chromium.org/gerrit/26451 Reviewed-by: Stefan Reinauer <reinauer@chromium.org>
* Change ec_command() to return negative values for errorsRandall Spangler2012-06-291-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | This is more compatible with kernel and u-boot, and will make it easier to share code between the ec project and those. BUG=none TEST=manual: ectool version -> should work normally on ec, do 'hostevent set 0x40000'. Then at root shell ectool queryec EC returned error result code 19 ectool flashread 0x100000 16 foo Reading 16 bytes at offset 1048576... EC returned error result code 2 Read error at offset 0 Signed-off-by: Randall Spangler <rspangler@chromium.org> Change-Id: I5e2a85f96c874d0730c14e1438a533649cd594f8 Reviewed-on: https://gerrit.chromium.org/gerrit/26359 Commit-Ready: Randall Spangler <rspangler@chromium.org> Reviewed-by: Randall Spangler <rspangler@chromium.org> Tested-by: Randall Spangler <rspangler@chromium.org>
* Split communication functions from host toolsVincent Palatin2012-05-241-67/+2
| | | | | | | | | | | | Preparatory work to re-use the tools on ARM boards using I2C communications. Signed-off-by: Vincent Palatin <vpalatin@chromium.org> BUG=None TEST=make BOARD=link && make BOARD=bds && make BOard=DAISY Change-Id: I31d41f30c3231a4a9349b939bf6bba871ed4c383
* de-LPCify the EC host interfaceVincent Palatin2012-05-151-32/+32
| | | | | | | | | | | | | Preparatory work to use common host command code between ARM and x86. Just rename constants, do not change the binary API. Signed-off-by: Vincent Palatin <vpalatin@chromium.org> BUG=chrome-os-partner:9614 TEST=make BOARD=link Change-Id: I534d427c9b50103273835a6f32a0ddb622c762b3
* Add LPC lightbar command to get the current sequence.Bill Richardson2012-05-081-1/+31
| | | | | | | | | | | | | | Instead of making the STOP command synchronous, we can just have the host-side app tell the EC to stop, then poll until it has. BUG=chrome-os-partner:9349 TEST=manual "make BOARD=link", then copy build/link/util/lbplay to the host and run it. Change-Id: I846924ae7994a498e0089197785cf239898fe2a3 Signed-off-by: Bill Richardson <wfrichar@chromium.org>
* Create host-side lightbar bikeshedding tool.Bill Richardson2012-04-261-0/+209
BUG=chrome-os-partner:7839 TEST=manual cd src/platform/ec make BOARD=link copy ./build/link/util/lbplay to the host and run it as root. Change-Id: I6a4a842b7500751185c8f4c2744f4389226bae9b Signed-off-by: Bill Richardson <wfrichar@chromium.org>