/* * Copyright (C) 2006, Intel Corporation * * This file is part of the Linux-ready Firmware Developer Kit * * This program file is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by the * Free Software Foundation;version 2.1 of the License. * * This library 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 Lesser General Public License * for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program in a file named COPYING; if not, write to the * Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301 USA */ #define _GNU_SOURCE #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include "../biostest.h" static void tone(int frequency, int duration) { FILE *file; int fd; uint32_t ioctlvalue; file = fopen("/dev/console", "w"); if (!file) return; fd = fileno(file); if (fd < 0) return; ioctlvalue = (duration << 16) | frequency; ioctl(fd, KDMKTONE, ioctlvalue); fclose(file); usleep(duration*1000); } static void do_tone_test(void) { int myHelloWin; newtComponent myHelloText, myHelloForm, myOk, myScales; int W,H; newtGetScreenSize(&W,&H); myHelloWin = newtOpenWindow(1+(W-55)/2, 1+(H-11)/2, 55, 11,"PC speaker test"); myHelloForm = newtForm(NULL,NULL,0); myHelloText = newtTextbox(3,2,52,1, 0); newtFormAddComponent(myHelloForm, myHelloText); newtTextboxSetText(myHelloText, "Three tones of different pitch will now sound. \n"); myScales = newtScale(3,4,49, 100); newtFormAddComponent(myHelloForm, myScales); myOk = newtButton(40,6, "Back"); newtFormAddComponent(myHelloForm, myOk); newtDrawForm(myHelloForm); newtRefresh(); tone(2000,1000); newtScaleSet(myScales, 33); newtRefresh(); tone(4000,1000); newtScaleSet(myScales, 65); newtRefresh(); tone(3000,1000); newtScaleSet(myScales, 100); newtRefresh(); newtDrawForm(myHelloForm); newtRefresh(); newtRunForm(myHelloForm); newtPopWindow(); } void run_test(void) { register_interactive_test("Speaker test", do_tone_test); }