]> git.alsa-project.org Git - alsa-utils.git/commitdiff
Remove obsolete power command from alsactl
authorTakashi Iwai <tiwai@suse.de>
Mon, 13 Mar 2006 19:39:17 +0000 (19:39 +0000)
committerTakashi Iwai <tiwai@suse.de>
Mon, 13 Mar 2006 19:39:17 +0000 (19:39 +0000)
Remove obsolete power command from alsactl.

alsactl/Makefile.am
alsactl/alsactl.c
alsactl/power.c [deleted file]

index e5bcb052953c3dd0e45ae10f3e5b9811c3f6c410..d21a496e63ae4dcb96ea63151dd4a35615467bf7 100644 (file)
@@ -2,5 +2,5 @@ sbin_PROGRAMS=alsactl
 man_MANS=alsactl.1
 EXTRA_DIST=alsactl.1
 
-alsactl_SOURCES=alsactl.c state.c power.c names.c
+alsactl_SOURCES=alsactl.c state.c names.c
 noinst_HEADERS=alsactl.h
index 2fd3b979f74fca7ece8ff1ee0ee2c9a80b523dcd..2770ee249dbb717abeb4848f3aabd2aaa08af954 100644 (file)
@@ -51,8 +51,6 @@ static void help(void)
        printf("                  to configuration file\n");
        printf("  restore<card #> load current driver setup for one or each soundcards\n");
        printf("                  from configuration file\n");
-       printf("  power [card #] [state]\n");
-       printf("                  get/set power state for one or each soundcards\n");
 }
 
 int main(int argc, char *argv[])
@@ -115,8 +113,6 @@ int main(int argc, char *argv[])
                if (!strcmp(cfgfile, SYS_ASOUNDRC))
                        cfgfile = SYS_ASOUNDNAMES;
                res = generate_names(cfgfile);
-       } else if (!strcmp(argv[optind], "power")) {
-               res = power((const char **)argv + optind + 1, argc - optind - 1);
        } else {
                fprintf(stderr, "alsactl: Unknown command '%s'...\n", 
                        argv[optind]);
diff --git a/alsactl/power.c b/alsactl/power.c
deleted file mode 100644 (file)
index ee6472c..0000000
+++ /dev/null
@@ -1,200 +0,0 @@
-/*
- *  Advanced Linux Sound Architecture Control Program
- *  Copyright (c) Jaroslav Kysela <perex@suse.cz>
- *
- *
- *   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.
- *
- *   You should have received a copy of the GNU General Public License
- *   along with this program; if not, write to the Free Software
- *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
- *
- */
-
-#include "aconfig.h"
-#include "version.h"
-#include <getopt.h>
-#include <stdarg.h>
-#include <stdio.h>
-#include <assert.h>
-#include <errno.h>
-#include <alsa/asoundlib.h>
-#include "alsactl.h"
-
-
-static int get_int_state(const char *str)
-{
-       if (!strcasecmp(str, "on"))
-               return SND_CTL_POWER_D0;
-       if (!strcasecmp(str, "off"))
-               return SND_CTL_POWER_D3hot;
-       if (*str == 'D' || *str == 'd') {
-               str++;
-               if (!strcmp(str, "0"))
-                       return SND_CTL_POWER_D0;
-               if (!strcmp(str, "1"))
-                       return SND_CTL_POWER_D1;
-               if (!strcmp(str, "2"))
-                       return SND_CTL_POWER_D2;
-               if (!strcmp(str, "3"))
-                       return SND_CTL_POWER_D3;
-               if (!strcmp(str, "3hot"))
-                       return SND_CTL_POWER_D3hot;
-               if (!strcmp(str, "3cold"))
-                       return SND_CTL_POWER_D3cold;
-       }
-       return -1;
-}
-
-static const char *get_str_state(int power_state)
-{
-       static char str[16];
-
-       switch (power_state) {
-       case SND_CTL_POWER_D0:
-               return "D0";
-       case SND_CTL_POWER_D1:
-               return "D1";
-       case SND_CTL_POWER_D2:
-               return "D2";
-       // return SND_CTL_POWER_D3;     /* it's same as D3hot */
-       case SND_CTL_POWER_D3hot:
-               return "D3hot";
-       case SND_CTL_POWER_D3cold:
-               return "D3cold";
-       default:
-               sprintf(str, "???0x%x", power_state);
-               return str;
-       }
-}
-
-static int show_power(int cardno)
-{
-       snd_ctl_t *handle;
-       char name[16];
-       unsigned int power_state;
-       int err;
-
-       sprintf(name, "hw:%d", cardno);
-       err = snd_ctl_open(&handle, name, 0);
-       if (err < 0) {
-               error("snd_ctl_open error: %s", snd_strerror(err));
-               return err;
-       }
-       err = snd_ctl_get_power_state(handle, &power_state);
-       if (err < 0) {
-               error("snd_ctl_get_power_state error: %s", snd_strerror(err));
-               snd_ctl_close(handle);
-               return err;
-       }
-       snd_ctl_close(handle);
-       printf("Power state for card #%d is %s\n", cardno, get_str_state(power_state));
-       return 0;
-}
-
-static int set_power(int cardno, unsigned int power_state)
-{
-       snd_ctl_t *handle;
-       char name[16];
-       int err;
-
-       sprintf(name, "hw:%d", cardno);
-       err = snd_ctl_open(&handle, name, 0);
-       if (err < 0) {
-               error("snd_ctl_open error: %s", snd_strerror(err));
-               return err;
-       }
-       err = snd_ctl_set_power_state(handle, power_state);
-       if (err < 0) {
-               error("snd_ctl_set_power_state error: %s", snd_strerror(err));
-               snd_ctl_close(handle);
-               return err;
-       }
-       err = snd_ctl_get_power_state(handle, &power_state);
-       if (err < 0) {
-               error("snd_ctl_get_power_state error: %s", snd_strerror(err));
-               snd_ctl_close(handle);
-               return err;
-       }
-       snd_ctl_close(handle);
-       printf("Power state for card #%d is %s\n", cardno, get_str_state(power_state));
-       return 0;
-}
-
-
-int power(const char *argv[], int argc)
-{
-       int power_state, err;
-       
-       if (argc == 0) {                /* show status only */
-               int card, first = 1;
-
-               card = -1;
-               /* find each installed soundcards */
-               while (1) {
-                       if (snd_card_next(&card) < 0)
-                               break;
-                       if (card < 0) {
-                               if (first) {
-                                       error("No soundcards found...");
-                                       return -ENODEV;
-                               }
-                               break;
-                       }
-                       first = 0;
-                       if ((err = show_power(card)) < 0)
-                               return err;
-               }
-               return 0;
-       }
-       power_state = get_int_state(argv[0]);
-       if (power_state >= 0) {
-               int card, first = 1;
-
-               card = -1;
-               /* find each installed soundcards */
-               while (1) {
-                       if (snd_card_next(&card) < 0)
-                               break;
-                       if (card < 0) {
-                               if (first) {
-                                       error("No soundcards found...");
-                                       return -ENODEV;
-                               }
-                               break;
-                       }
-                       first = 0;
-                       if ((err = set_power(card, power_state)))
-                               return err;
-               }
-       } else {
-               int cardno;
-
-               cardno = snd_card_get_index(argv[0]);
-               if (cardno < 0) {
-                       error("Cannot find soundcard '%s'...", argv[0]);
-                       return -ENODEV;
-               }
-               if (argc > 1) {
-                       power_state = get_int_state(argv[1]);
-                       if (power_state < 0) {
-                               error("Invalid power state '%s'...", argv[1]);
-                               return -EINVAL;
-                       }
-                       if ((err = set_power(cardno, power_state)) < 0)
-                               return err;
-               } else {
-                       if ((err = show_power(cardno)) < 0)
-                               return err;
-               }
-       }
-       return 0;
-}