summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJuergen Beisert <jbe@pengutronix.de>2011-11-12 23:25:48 +0100
committerJuergen Beisert <jbe@pengutronix.de>2011-11-12 23:31:53 +0100
commitae38bfd31407a42c14b9400f8a1c55ba3cf8bead (patch)
tree42f35f7c39e74ccc4ae66ae7cc2f3e058f8fdd72
parentf147e014a02d26662fda42e599772d64155871a1 (diff)
downloadOSELAS.BSP-Pengutronix-Mini6410-ae38bfd31407a42c14b9400f8a1c55ba3cf8bead.tar.gz
OSELAS.BSP-Pengutronix-Mini6410-ae38bfd31407a42c14b9400f8a1c55ba3cf8bead.tar.xz
Platform: add a small tool to 'ring' the beeper
Signed-off-by: Juergen Beisert <jbe@pengutronix.de>
-rw-r--r--configs/platform-friendlyarm-mini6410/Changelog4
-rw-r--r--configs/platform-friendlyarm-mini6410/local_src/ring-bell-1.0/Makefile24
-rw-r--r--configs/platform-friendlyarm-mini6410/local_src/ring-bell-1.0/ring-bell.c90
-rw-r--r--configs/platform-friendlyarm-mini6410/rules/ring-bell.in12
-rw-r--r--configs/platform-friendlyarm-mini6410/rules/ring-bell.make61
-rw-r--r--documentation/plain_sources/special_notes.tex22
6 files changed, 212 insertions, 1 deletions
diff --git a/configs/platform-friendlyarm-mini6410/Changelog b/configs/platform-friendlyarm-mini6410/Changelog
index 6c9c4c7..adaeba7 100644
--- a/configs/platform-friendlyarm-mini6410/Changelog
+++ b/configs/platform-friendlyarm-mini6410/Changelog
@@ -1,6 +1,8 @@
2011-11-12 Juergen Beisert <jbe@pengutronix.de>
- * Platform: Back to development
+ * Platform:
+ - Back to development
+ - add a small tool to 'ring' the beeper
* Kernel 3.0:
- keep in sync with stable release .9
* Kernel 3.1:
diff --git a/configs/platform-friendlyarm-mini6410/local_src/ring-bell-1.0/Makefile b/configs/platform-friendlyarm-mini6410/local_src/ring-bell-1.0/Makefile
new file mode 100644
index 0000000..b4353aa
--- /dev/null
+++ b/configs/platform-friendlyarm-mini6410/local_src/ring-bell-1.0/Makefile
@@ -0,0 +1,24 @@
+#
+# Simple development makefile
+#
+
+#
+# add more flags here,
+# but don't remove the "+="
+#
+CFLAGS += -O2 -g -Wall #-Wsign-compare -Wfloat-equal -Wformat-security #-Werror
+CPPFLAGS +=
+LDFLAGS +=
+PREFIX := /usr
+
+all: ring-bell
+
+clean:
+ -rm -f ring-bell
+
+install: ring-bell
+ cp ring-bell $(DESTDIR)$(PREFIX)/bin/ring-bell
+
+.PHONY: all install clean
+
+# end of development makefile
diff --git a/configs/platform-friendlyarm-mini6410/local_src/ring-bell-1.0/ring-bell.c b/configs/platform-friendlyarm-mini6410/local_src/ring-bell-1.0/ring-bell.c
new file mode 100644
index 0000000..7e43a63
--- /dev/null
+++ b/configs/platform-friendlyarm-mini6410/local_src/ring-bell-1.0/ring-bell.c
@@ -0,0 +1,90 @@
+/*
+ * Copyright (c) 2011 Juergen Beisert <kernel@pengutronix.de>
+ *
+ * This code is derived from the 'evtest' sources:
+ * Copyright (c) 1999-2000 Vojtech Pavlik
+ * Copyright (c) 2009 Red Hat, Inc
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * Purpose:
+ * This is a small demo how to create kernel input subsystem related events
+ * and to ring the bell device. Regular way would be to echo an alert into the
+ * current TTY device. But for some embedded devices there is no TTY, because it
+ * runs only a graphical application.
+ */
+
+#define _XOPEN_SOURCE 500 /* for usleep() */
+
+#include <stdint.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <unistd.h>
+
+#include <linux/version.h>
+#include <linux/input.h>
+
+static void dump_help(const char *name)
+{
+ printf("Help: Ring the bell (or any other noise the system is able to do)\n");
+ printf("Usage: %s <event device>\n", name);
+ exit(EXIT_FAILURE);
+}
+
+static int ring_bell(int fd)
+{
+ ssize_t s;
+ struct input_event ev;
+
+/* ev.time = ??; TODO */
+ ev.type = EV_SND;
+ ev.code = SND_BELL;
+ ev.value = 1; /* enable (ring) the bell */
+
+ s = write(fd, &ev, sizeof(ev));
+ if (s == -1) {
+ perror("Writing bell event");
+ return -1;
+ }
+
+ usleep(100 * 1000); /* 100 ms */
+
+ ev.value = 0; /* stop bell from ringing */
+
+ s = write(fd, &ev, sizeof(ev));
+ if (s == -1) {
+ perror("Writing bell event");
+ return -1;
+ }
+
+ return EXIT_SUCCESS;
+}
+
+int main(int argc, char *argv[])
+{
+ int fd, rc;
+
+ if (argc < 2)
+ dump_help(argv[0]);
+
+ fd = open(argv[1], O_WRONLY);
+ if (fd == -1) {
+ perror("Open event device");
+ exit(EXIT_FAILURE);
+ }
+
+ rc = ring_bell(fd);
+ close(fd);
+ exit(rc);
+}
diff --git a/configs/platform-friendlyarm-mini6410/rules/ring-bell.in b/configs/platform-friendlyarm-mini6410/rules/ring-bell.in
new file mode 100644
index 0000000..4669bc3
--- /dev/null
+++ b/configs/platform-friendlyarm-mini6410/rules/ring-bell.in
@@ -0,0 +1,12 @@
+## SECTION=test_suites
+
+config RING_BELL
+ tristate
+ prompt "ring-bell"
+ help
+ A small demo how to ring the bell from userland if no TTY is
+ available. On the HMI10 platform this tool must be used in accordance
+ with the pwm-beeper event device.
+ If a regular TTY is available also an "echo -e "\a" > /dev/tty0"
+ rings the bell.
+
diff --git a/configs/platform-friendlyarm-mini6410/rules/ring-bell.make b/configs/platform-friendlyarm-mini6410/rules/ring-bell.make
new file mode 100644
index 0000000..406b59a
--- /dev/null
+++ b/configs/platform-friendlyarm-mini6410/rules/ring-bell.make
@@ -0,0 +1,61 @@
+# -*-makefile-*-
+#
+# Copyright (C) 2011 by Juergen Beisert <jbe@pengutronix.de>
+#
+# See CREDITS for details about who has contributed to this project.
+#
+# For further information about the PTXdist project and license conditions
+# see the README file.
+#
+
+#
+# We provide this package
+#
+PACKAGES-$(PTXCONF_RING_BELL) += ring-bell
+
+#
+# Paths and names
+#
+RING_BELL_VERSION := 1.0
+RING_BELL_MD5 :=
+RING_BELL := ring-bell
+RING_BELL_URL := file://$(PTXDIST_PLATFORMCONFIGDIR)/local_src/$(RING_BELL)-$(RING_BELL_VERSION)
+RING_BELL_DIR := $(BUILDDIR)/$(RING_BELL)
+RING_BELL_LICENSE := GPLv2
+
+# ----------------------------------------------------------------------------
+# Prepare
+# ----------------------------------------------------------------------------
+
+RING_BELL_CONF_TOOL := NO
+RING_BELL_MAKE_ENV := $(CROSS_ENV)
+
+# ----------------------------------------------------------------------------
+# Target-Install
+# ----------------------------------------------------------------------------
+
+$(STATEDIR)/ring-bell.targetinstall:
+ @$(call targetinfo)
+
+ @$(call install_init, ring-bell)
+ @$(call install_fixup, ring-bell,PRIORITY,optional)
+ @$(call install_fixup, ring-bell,SECTION,base)
+ @$(call install_fixup, ring-bell,AUTHOR,"Juergen Beisert <jbe@pengutronix.de>")
+ @$(call install_fixup, ring-bell,DESCRIPTION, "ring bell via input subsystem")
+
+ @$(call install_copy, ring-bell, 0, 0, 0755, -, /usr/bin/ring-bell)
+ @$(call install_finish, ring-bell)
+
+ @$(call touch)
+
+# ----------------------------------------------------------------------------
+# Clean
+# ----------------------------------------------------------------------------
+
+$(STATEDIR)/ring-bell.clean:
+ @$(call targetinfo)
+ @-cd $(RING_BELL_DIR) && \
+ $(RING_BELL_ENV) $(RING_BELL_PATH) $(MAKE) clean
+ @$(call clean_pkg, RING_BELL)
+
+# vim: syntax=make
diff --git a/documentation/plain_sources/special_notes.tex b/documentation/plain_sources/special_notes.tex
index 961adc2..2eb683c 100644
--- a/documentation/plain_sources/special_notes.tex
+++ b/documentation/plain_sources/special_notes.tex
@@ -665,6 +665,28 @@ setup instead of the plain event node.
%----------------------------------------------------------------------------
+\section{Buzzer} \label{sec:Buzzer}
+%---------------
+
+The buzzer on the Mini6410 will be triggered by a regular alert in a console.
+So, a simple
+
+\begin{ptxshell}[escapechar=|]{^}
+# echo -e "\a"
+\end{ptxshell}
+
+can make a noise. But this only works if local console support is enabled.
+
+If no local console is available the small \texttt{ring-bell} tool will help.
+
+\begin{ptxshell}[escapechar=|]{^}
+# ring-bell /dev/input/beeper
+\end{ptxshell}
+
+will make some noise for you.
+
+%----------------------------------------------------------------------------
+
% note: not supported yet
%
% \section{Audio} \label{sec:AUDIO}