All of lore.kernel.org
 help / color / mirror / Atom feed
* adding volume to raw-midi device
@ 2006-09-26 22:03 Pamela K. Clift
  2006-09-27  7:28 ` Clemens Ladisch
  0 siblings, 1 reply; 4+ messages in thread
From: Pamela K. Clift @ 2006-09-26 22:03 UTC (permalink / raw)
  To: alsa-devel


I am new to alsa and I am trying to write a raw-midi device driver.  When I tried to add the volume control I could not compile the file anymore.  I am hoping someone can help me and see what I am missing.  I have looked in the Writing an Alsa Driver chapter 6 and I have looked at dummy.c .  I believe I am following what they say to do but when I compile the file I get many errors including "warning: "struct snd_ctl_elem_info declared inside parameter list"   I have at the top of my file #include <sound/control.h> along with the other includes I see in the sample files.  Below is the code I added.

static int snd_ld_volume_info(struct snd_kcontrol *kcontrol,
                 struct snd_ctl_elem_info *uinfo)
{
    uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
    uinfo->count = 1;
    uinfo->value.integer.min = 0;
    uinfo->value.integer.max = 127;
    return 0;
}
 
static int snd_ld_volume_get(struct snd_kcontrol *kcontrol,
                struct snd_ctl_elem_value *ucontrol)
{
    struct snd_card_ld *ld = snd_kcontrol_chip(kcontrol);
    int addr = kcontrol->private_value;

    spin_lock_irq(&ld->mixer_lock);
    ucontrol->value.integer.value[0] = ld->mixer_volume[addr];
    spin_unlock_irq(&ld->mixer_lock);
    return 0;
}

static int snd_ld_volume_put(struct snd_kcontrol *kcontrol,
                struct snd_ctl_elem_value *ucontrol)
{
    struct snd_card_ld *ld = snd_kcontrol_chip(kcontrol);
    int changed = 0, addr = kcontrol->private_value;
    int value;

    value = ucontrol->value.integer.value[0];
    if (value < 0)
        value = 0;
    if (value > 127)
        value = 127;
    spin_lock_irq(&ld->mixer_lock);
    changed = ld->mixer_volume[addr] != value;
    ld->mixer_volume[addr] = value;
    spin_unlock_irq(&ld->mixer_lock);
    return changed;
}

static struct snd_kcontrol_new snd_ld_volume = {
  .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 
  .name = "Master Playback Volume", 
  .index = 0,
  .info = snd_ld_volume_info,
  .get = snd_ld_volume_get, 
  .put = snd_ld_volume_put,
  .private_value = addr
};

static int __init snd_card_ld_new_mixer(struct snd_card_ld *ld)
{
  struct snd_card *card = ld->card;
  int err;

  snd_assert(ld != NULL, return -EINVAL);
  spin_lock_init(&ld->mixer_lock);
  strcpy(card->mixername, "LD Mixer");

  if ((err = snd_ctl_add(card, snd_ctl_new1(&snd_ld_volume, ld)))
                                                                   < 0)
    return err;
  return 0;
}


static int __init snd_card_ld_probe(int dev)
{
  snd_card_t *card;
  struct snd_card_ld *ld;
  int err;

(many things, deleted here since I believe not relevent to problem)

  /* add mixer volume */
  if ((err = snd_card_ld_new_mixer(ld)) < 0)
    return err;

 






-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: adding volume to raw-midi device
  2006-09-26 22:03 Pamela K. Clift
@ 2006-09-27  7:28 ` Clemens Ladisch
  0 siblings, 0 replies; 4+ messages in thread
From: Clemens Ladisch @ 2006-09-27  7:28 UTC (permalink / raw)
  To: Pamela K. Clift, alsa-devel

Pamela K. Clift wrote:
> when I compile the file I get many errors including "warning:
> struct snd_ctl_elem_info declared inside parameter list"   I have at
> the top of my file #include <sound/control.h> along with the other
> includes I see in the sample files.

struct snd_ctl_elem_info is defined in <sound/asound.h> which is
automatically included by control.h, so I guess the compiler got
confused by some earlier error.

Please show the exact output of the compiler.


Regards,
Clemens

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV

^ permalink raw reply	[flat|nested] 4+ messages in thread

* adding volume to raw-midi device
@ 2006-10-27 17:20 Pamela K. Clift
  2006-10-27 17:27 ` Lee Revell
  0 siblings, 1 reply; 4+ messages in thread
From: Pamela K. Clift @ 2006-10-27 17:20 UTC (permalink / raw)
  To: alsa-devel

[-- Attachment #1: Type: text/plain, Size: 3112 bytes --]

I am starting this email again.  I know I had one response before but I can not get to it.  Most of our office building has burnt down to the ground.  It has taken a while to get things back up and for me to be able to get back to this.




I am new to alsa and I am trying to write a raw-midi device driver.  When I tried to add the volume control I could not compile the file anymore.  I am hoping someone can help me and see what I am missing.  I have looked in the Writing an Alsa Driver chapter 6 and I have looked at dummy.c .  I believe I am following what they say to do but when I compile the file I get many errors including "warning: "struct snd_ctl_elem_info declared inside parameter list"   I have at the top of my file #include <sound/control.h> along with the other includes I see in the sample files.  Below is the code I added.

static int snd_ld_volume_info(struct snd_kcontrol *kcontrol,
                 struct snd_ctl_elem_info *uinfo)
{
    uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
    uinfo->count = 1;
    uinfo->value.integer.min = 0;
    uinfo->value.integer.max = 127;
    return 0;
}
 
static int snd_ld_volume_get(struct snd_kcontrol *kcontrol,
                struct snd_ctl_elem_value *ucontrol)
{
    struct snd_card_ld *ld = snd_kcontrol_chip(kcontrol);
    int addr = kcontrol->private_value;

    spin_lock_irq(&ld->mixer_lock);
    ucontrol->value.integer.value[0] = ld->mixer_volume[addr];
    spin_unlock_irq(&ld->mixer_lock);
    return 0;
}

static int snd_ld_volume_put(struct snd_kcontrol *kcontrol,
                struct snd_ctl_elem_value *ucontrol)
{
    struct snd_card_ld *ld = snd_kcontrol_chip(kcontrol);
    int changed = 0, addr = kcontrol->private_value;
    int value;

    value = ucontrol->value.integer.value[0];
    if (value < 0)
        value = 0;
    if (value > 127)
        value = 127;
    spin_lock_irq(&ld->mixer_lock);
    changed = ld->mixer_volume[addr] != value;
    ld->mixer_volume[addr] = value;
    spin_unlock_irq(&ld->mixer_lock);
    return changed;
}

static struct snd_kcontrol_new snd_ld_volume = {
  .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 
  .name = "Master Playback Volume", 
  .index = 0,
  .info = snd_ld_volume_info,
  .get = snd_ld_volume_get, 
  .put = snd_ld_volume_put,
  .private_value = addr
};

static int __init snd_card_ld_new_mixer(struct snd_card_ld *ld)
{
  struct snd_card *card = ld->card;
  int err;

  snd_assert(ld != NULL, return -EINVAL);
  spin_lock_init(&ld->mixer_lock);
  strcpy(card->mixername, "LD Mixer");

  if ((err = snd_ctl_add(card, snd_ctl_new1(&snd_ld_volume, ld)))
                                                                   < 0)
    return err;
  return 0;
}

static int __init snd_card_ld_probe(int dev)
{
  snd_card_t *card;
  struct snd_card_ld *ld;
  int err;

(many things, deleted here since I believe not relevent to problem)

  /* add mixer volume */
  if ((err = snd_card_ld_new_mixer(ld)) < 0)
    return err;

attached is the error output from trying to compile this.
 <<output2.txt>> 

[-- Attachment #2: output2.txt --]
[-- Type: text/plain, Size: 5717 bytes --]

/usr/src/alsa/alsa-driver-1.0.8/drivers/cpld.c:997: warning: "struct snd_ctl_elem_info" declared inside parameter list
/usr/src/alsa/alsa-driver-1.0.8/drivers/cpld.c:997: warning: its scope is only this definition or declaration, which is probably not what you want
/usr/src/alsa/alsa-driver-1.0.8/drivers/cpld.c:997: warning: "struct snd_kcontrol" declared inside parameter list
/usr/src/alsa/alsa-driver-1.0.8/drivers/cpld.c: In function `snd_ld_volume_info':
/usr/src/alsa/alsa-driver-1.0.8/drivers/cpld.c:999: error: dereferencing pointer to incomplete type
/usr/src/alsa/alsa-driver-1.0.8/drivers/cpld.c:1000: error: dereferencing pointer to incomplete type
/usr/src/alsa/alsa-driver-1.0.8/drivers/cpld.c:1001: error: dereferencing pointer to incomplete type
/usr/src/alsa/alsa-driver-1.0.8/drivers/cpld.c:1002: error: dereferencing pointer to incomplete type
/usr/src/alsa/alsa-driver-1.0.8/drivers/cpld.c: At top level:
/usr/src/alsa/alsa-driver-1.0.8/drivers/cpld.c:1007: warning: "struct snd_ctl_elem_value" declared inside parameter list
/usr/src/alsa/alsa-driver-1.0.8/drivers/cpld.c:1007: warning: "struct snd_kcontrol" declared inside parameter list
/usr/src/alsa/alsa-driver-1.0.8/drivers/cpld.c: In function `snd_ld_volume_get':
/usr/src/alsa/alsa-driver-1.0.8/drivers/cpld.c:1009: error: dereferencing pointer to incomplete type
/usr/src/alsa/alsa-driver-1.0.8/drivers/cpld.c:1010: error: dereferencing pointer to incomplete type
/usr/src/alsa/alsa-driver-1.0.8/drivers/cpld.c:1013: error: dereferencing pointer to incomplete type
/usr/src/alsa/alsa-driver-1.0.8/drivers/cpld.c: At top level:
/usr/src/alsa/alsa-driver-1.0.8/drivers/cpld.c:1019: warning: "struct snd_ctl_elem_value" declared inside parameter list
/usr/src/alsa/alsa-driver-1.0.8/drivers/cpld.c:1019: warning: "struct snd_kcontrol" declared inside parameter list
/usr/src/alsa/alsa-driver-1.0.8/drivers/cpld.c: In function `snd_ld_volume_put':
/usr/src/alsa/alsa-driver-1.0.8/drivers/cpld.c:1021: error: dereferencing pointer to incomplete type
/usr/src/alsa/alsa-driver-1.0.8/drivers/cpld.c:1022: error: dereferencing pointer to incomplete type
/usr/src/alsa/alsa-driver-1.0.8/drivers/cpld.c:1025: error: dereferencing pointer to incomplete type
/usr/src/alsa/alsa-driver-1.0.8/drivers/cpld.c: At top level:
/usr/src/alsa/alsa-driver-1.0.8/drivers/cpld.c:1037: error: variable `snd_ld_volume' has initializer but incomplete type
/usr/src/alsa/alsa-driver-1.0.8/drivers/cpld.c:1038: error: unknown field `iface' specified in initializer
/usr/src/alsa/alsa-driver-1.0.8/drivers/cpld.c:1038: warning: excess elements in struct initializer
/usr/src/alsa/alsa-driver-1.0.8/drivers/cpld.c:1038: warning: (near initialization for `snd_ld_volume')
/usr/src/alsa/alsa-driver-1.0.8/drivers/cpld.c:1039: error: unknown field `name' specified in initializer
/usr/src/alsa/alsa-driver-1.0.8/drivers/cpld.c:1039: warning: excess elements in struct initializer
/usr/src/alsa/alsa-driver-1.0.8/drivers/cpld.c:1039: warning: (near initialization for `snd_ld_volume')
/usr/src/alsa/alsa-driver-1.0.8/drivers/cpld.c:1040: error: unknown field `index' specified in initializer
/usr/src/alsa/alsa-driver-1.0.8/drivers/cpld.c:1040: warning: excess elements in struct initializer
/usr/src/alsa/alsa-driver-1.0.8/drivers/cpld.c:1040: warning: (near initialization for `snd_ld_volume')
/usr/src/alsa/alsa-driver-1.0.8/drivers/cpld.c:1041: error: unknown field `info' specified in initializer
/usr/src/alsa/alsa-driver-1.0.8/drivers/cpld.c:1041: warning: excess elements in struct initializer
/usr/src/alsa/alsa-driver-1.0.8/drivers/cpld.c:1041: warning: (near initialization for `snd_ld_volume')
/usr/src/alsa/alsa-driver-1.0.8/drivers/cpld.c:1042: error: unknown field `get' specified in initializer
/usr/src/alsa/alsa-driver-1.0.8/drivers/cpld.c:1042: warning: excess elements in struct initializer
/usr/src/alsa/alsa-driver-1.0.8/drivers/cpld.c:1042: warning: (near initialization for `snd_ld_volume')
/usr/src/alsa/alsa-driver-1.0.8/drivers/cpld.c:1043: error: unknown field `put' specified in initializer
/usr/src/alsa/alsa-driver-1.0.8/drivers/cpld.c:1043: warning: excess elements in struct initializer
/usr/src/alsa/alsa-driver-1.0.8/drivers/cpld.c:1043: warning: (near initialization for `snd_ld_volume')
/usr/src/alsa/alsa-driver-1.0.8/drivers/cpld.c:1044: error: unknown field `private_value' specified in initializer
/usr/src/alsa/alsa-driver-1.0.8/drivers/cpld.c:1045: warning: excess elements in struct initializer
/usr/src/alsa/alsa-driver-1.0.8/drivers/cpld.c:1045: warning: (near initialization for `snd_ld_volume')
/usr/src/alsa/alsa-driver-1.0.8/drivers/cpld.c: In function `snd_card_ld_new_mixer':
/usr/src/alsa/alsa-driver-1.0.8/drivers/cpld.c:1054: error: dereferencing pointer to incomplete type
/usr/src/alsa/alsa-driver-1.0.8/drivers/cpld.c:1056: warning: passing arg 1 of `snd_ctl_new1' from incompatible pointer type
/usr/src/alsa/alsa-driver-1.0.8/drivers/cpld.c: In function `snd_card_cpld_probe':
/usr/src/alsa/alsa-driver-1.0.8/drivers/cpld.c:1102: error: `cpld' undeclared (first use in this function)
/usr/src/alsa/alsa-driver-1.0.8/drivers/cpld.c:1102: error: (Each undeclared identifier is reported only once
/usr/src/alsa/alsa-driver-1.0.8/drivers/cpld.c:1102: error: for each function it appears in.)
/usr/src/alsa/alsa-driver-1.0.8/drivers/cpld.c: At top level:
/usr/src/alsa/alsa-driver-1.0.8/drivers/cpld.c:1037: error: storage size of `snd_ld_volume' isn't known
make[4]: *** [/usr/src/alsa/alsa-driver-1.0.8/drivers/cpld.o] Error 1
make[3]: *** [/usr/src/alsa/alsa-driver-1.0.8/drivers] Error 2
make[2]: *** [_module_/usr/src/alsa/alsa-driver-1.0.8] Error 2
make[1]: *** [modules] Error 2
make: *** [compile] Error 2

[-- Attachment #3: Type: text/plain, Size: 373 bytes --]

-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642

[-- Attachment #4: Type: text/plain, Size: 161 bytes --]

_______________________________________________
Alsa-devel mailing list
Alsa-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/alsa-devel

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: adding volume to raw-midi device
  2006-10-27 17:20 adding volume to raw-midi device Pamela K. Clift
@ 2006-10-27 17:27 ` Lee Revell
  0 siblings, 0 replies; 4+ messages in thread
From: Lee Revell @ 2006-10-27 17:27 UTC (permalink / raw)
  To: Pamela K. Clift; +Cc: alsa-devel

On Fri, 2006-10-27 at 10:20 -0700, Pamela K. Clift wrote:
> I am starting this email again.  I know I had one response before but I can not get to it.  Most of our office building has burnt down to the ground.  It has taken a while to get things back up and for me to be able to get back to this.
> 
> 
> 
> 
> I am new to alsa and I am trying to write a raw-midi device driver.  When I tried to add the volume control I could not compile the file anymore.  I am hoping someone can help me and see what I am missing.  I have looked in the Writing an Alsa Driver chapter 6 and I have looked at dummy.c .  I believe I am following what they say to do but when I compile the file I get many errors including "warning: "struct snd_ctl_elem_info declared inside parameter list"   I have at the top of my file #include <sound/control.h> along with the other includes I see in the sample files.  Below is the code I added.
> 

ALSA used to typedef all of these structs.  Some people thought that
obfuscated the code so the typedefs were removed between 1.0.8 and the
current version.  Looks like you're trying to add new-style code to old
ALSA.

Should compile against 1.0.8 if you replace "struct snd_foo" with
"snd_foo_t" for all foo...

Lee


-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2006-10-27 17:27 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-10-27 17:20 adding volume to raw-midi device Pamela K. Clift
2006-10-27 17:27 ` Lee Revell
  -- strict thread matches above, loose matches on Subject: below --
2006-09-26 22:03 Pamela K. Clift
2006-09-27  7:28 ` Clemens Ladisch

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.