Commit 67eddefe authored by aTc's avatar aTc

pyra-hacks : moved from pyra-scripts, added pyra_volumed

parent 91f04611
CC = $(CROSS_COMPILE)gcc
CFLAGS = -Wall -O2 -ggdb
TOPDIR = $(shell pwd)
export TOPDIR
TARGETS = pyra_volumed
.PHONY: all install clean
all: $(TARGETS)
clean:
$(RM) $(TARGETS)
pyra_volumed: LDLIBS+= -lasound -liio
install:
install -d "$(DESTDIR)/usr/bin"
install -m 755 -t "$(DESTDIR)/usr/bin" "$(TOPDIR)/pyra_volumed"
install -d "$(DESTDIR)/lib/systemd/system"
install -m 644 -t "$(DESTDIR)/lib/systemd/system/" "$(TOPDIR)/pyra_volumed.service"
install -d "$(DESTDIR)/lib/udev/rules.d/"
install -m 644 -t "$(DESTDIR)/lib/udev/rules.d/" "$(TOPDIR)/nubs.rules"
pyra-hacks (0.1) stretch; urgency=medium
* Initial Release.
-- Pyra Dev <dev@pyra-handheld.com> Wed, 17 Jul 2019 11:12:44 +0200
Source: pyra-hacks
Section: misc
Priority: optional
Maintainer: Pyra Dev <dev@pyra-handheld.com>
Build-Depends: debhelper (>= 9), dh-systemd, systemd, libasound2-dev,
libiio-dev
Standards-Version: 3.9.8
Homepage: http://dev.pyra-handheld.com/packages/pyra-hacks.git
Package: pyra-hacks
Architecture: any
Depends: ${misc:Depends}, libasound2, libiio0
Description: Some hacks to quickly get around a few problems
These things should be properly fixed at some stage.
Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
Upstream-Name: pyra-hacks
Source: http://dev.pyra-handheld.com/packages/pyra-hacks.git
Files: *
Copyright: 2019 Pyra Dev <dev@pyra-handheld.com>
License: MIT
Files: debian/*
Copyright: 2019 Pyra Dev <dev@pyra-handheld.com>
License: MIT
License: MIT
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following conditions:
.
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
pyra-hacks-dbgsym_0.1_armhf.deb debug optional
pyra-hacks_0.1_armhf.buildinfo misc optional
pyra-hacks_0.1_armhf.deb misc optional
#!/usr/bin/make -f
# See debhelper(7) (uncomment to enable)
# output every command that modifies files on the build system.
#export DH_VERBOSE = 1
# see FEATURE AREAS in dpkg-buildflags(1)
#export DEB_BUILD_MAINT_OPTIONS = hardening=+all
# see ENVIRONMENT in dpkg-buildflags(1)
# package maintainers to append CFLAGS
#export DEB_CFLAGS_MAINT_APPEND = -Wall -pedantic
# package maintainers to append LDFLAGS
#export DEB_LDFLAGS_MAINT_APPEND = -Wl,--as-needed
%:
dh $@ --with systemd
KERNELS=="input*", SUBSYSTEMS=="input", ATTRS{name}=="nub0", RUN+="/bin/sh -c 'echo absolute > /proc/pandora/nub0/mode' "
KERNELS=="input*", SUBSYSTEMS=="input", ATTRS{name}=="nub1", RUN+="/bin/sh -c 'echo absolute > /proc/pandora/nub1/mode' "
// pyra volumed
// reads volumewheel value and applies it to the mixer
// temporary daemon, should be made part of the input daemon
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <alsa/asoundlib.h>
#include <unistd.h>
#include <iio.h>
#define DEVNAME "palmas-gpadc"
#define CHANNEL "voltage2"
#define CARD "hw:CARD=L15"
#define SELEM "Handsfree"
int main(int argc,char **argv)
{
struct iio_context *ctx;
ctx=iio_create_default_context();
long min,max;
snd_mixer_t *handle;
snd_mixer_selem_id_t *sid;
snd_mixer_open(&handle,0);
snd_mixer_attach(handle,CARD);
snd_mixer_selem_register(handle,NULL,NULL);
snd_mixer_load(handle);
snd_mixer_selem_id_alloca(&sid);
snd_mixer_selem_id_set_index(sid, 0);
snd_mixer_selem_id_set_name(sid, SELEM);
snd_mixer_elem_t* elem = snd_mixer_find_selem(handle, sid);
snd_mixer_selem_get_playback_volume_range(elem, &min, &max);
const struct iio_device *dev=iio_context_find_device(ctx,DEVNAME);
if(dev)
{
//printf("found device\n");
struct iio_channel *ch=iio_device_find_channel(dev,CHANNEL,0);
if(ch)
{
//printf("found channel\n");
const char *attr=iio_channel_find_attr(ch,"input");
const char *attraw=iio_channel_find_attr(ch,"raw");
double val;
double raw;
int pv=-1;
while(true)
{
//iio_channel_attr_read_double(ch,attr,&val);
iio_channel_attr_read_double(ch,attraw,&raw);
long volume=raw*max/2052;
if(volume!=pv)
{
snd_mixer_selem_set_playback_volume_all(elem, volume);
pv=volume;
}
//printf("%f : %f : %d \n",val,raw,volume);
usleep(100000);
}
}
}
iio_context_destroy(ctx);
snd_mixer_close(handle);
return 0;
}
[Unit]
Description=Pyra Volume Daemon
Documentation=https://dev.pyra-handheld.com/packages/pyra-hacks
[Service]
ExecStart=/usr/bin/pyra_volumed
KillMode=process
Restart=on-failure
[Install]
WantedBy=multi-user.target
Alias=pyra_volumed.service
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment