Commit 48305b99 authored by Jeffrey Lee's avatar Jeffrey Lee
Browse files

Allow mixer devices to indicate the range of supported gain values

Detail:
  This adds support for version 0.1 of the HAL mixer device API. Mixer devices which implement this version of the API are able to indicate the min/max gain values each mixer supports, along with the smallest gain step.
  Docs/SoundCtrl - Updated to describe how this new information is exposed to RISC OS
  h/MixerDevice, hdr/MixerDevice - Updated mixer device structure definitions
  c/module - Added code to read gain information if present. Also fixed runtime mixer registration/deregistration to accept any device of version 0.x instead of 0.0
Admin:
  Tested in OMAP3 ROM & Tungsten ROM softload.


Version 1.01. Tagged as 'SoundCtrl-1_01'
parent 3429941c
......@@ -20,10 +20,14 @@ SoundControl module provides
r1 -> word-aligned block
r2 = block size (may be 0)
Out: block filled with as many as poss of following blocks:
+0,+1 flags: bit 0 set => fixed
bit 1 set => mono
bit 2 set => muted by default
+2,+3 category
byte pos content
0-1 flags: bit 0 set => fixed
bit 1 set => mono
bit 2 set => muted by default
2-3 category
4-7 minimum gain (dB*16)
8-11 maximum gain (dB*16)
12-15 minimum step size/granularity (dB*16)
r0,r1 preserved
r2 decremented by number of bytes needed for complete description
......@@ -32,18 +36,19 @@ SoundControl module provides
r4 = number of blocks placed in buffer
Should be called twice, first to determine buffer size, then to fill in buffer.
This is to allow block to be enlarged in future.
Currently, valid block sizes are 4 bytes and 16 bytes.
* SWI SoundControl_SetMix is equivalent SWI to *MixVolume
r0 = system
r1 = category
r2 = channel index
r3 = mute
r4 = gain
r3 = mute (0/1)
r4 = gain (dB*16)
* SWI SoundControl_GetMix
r0 = system
r1 = category
r2 = channel index
on exit:
r3 = mute
r4 = gain
r3 = mute (0/1)
r4 = gain (dB*16)
/* (1.00)
/* (1.01)
*
* This file is automatically maintained by srccommit, do not edit manually.
* Last processed by srccommit version: 1.68.
* Last processed by srccommit version: 1.1.
*
*/
#define Module_MajorVersion_CMHG 1.00
#define Module_MajorVersion_CMHG 1.01
#define Module_MinorVersion_CMHG
#define Module_Date_CMHG 17 Feb 2003
#define Module_Date_CMHG 21 Jan 2012
#define Module_MajorVersion "1.00"
#define Module_Version 100
#define Module_MajorVersion "1.01"
#define Module_Version 101
#define Module_MinorVersion ""
#define Module_Date "17 Feb 2003"
#define Module_Date "21 Jan 2012"
#define Module_ApplicationDate "17-Feb-03"
#define Module_ApplicationDate "21-Jan-12"
#define Module_ComponentName "SoundCtrl"
#define Module_ComponentPath "RiscOS/Sources/Audio/SoundCtrl"
#define Module_ComponentPath "castle/RiscOS/Sources/Audio/SoundCtrl"
#define Module_FullVersion "1.00"
#define Module_HelpVersion "1.00 (17 Feb 2003)"
#define Module_LibraryVersionInfo "1:00"
#define Module_FullVersion "1.01"
#define Module_HelpVersion "1.01 (21 Jan 2012)"
#define Module_LibraryVersionInfo "1:1"
......@@ -30,7 +30,7 @@
#include "modhdr.h"
#include "resmess.h"
#define LAST_KNOWN_DEVICE_VERSION 0
#define LAST_KNOWN_DEVICE_MAJOR_VERSION 0
typedef struct system
{
......@@ -147,14 +147,14 @@ void module_Service(int service_number, _kernel_swi_regs *r, void *pw)
switch (r->r[0] & 0xFF)
{
case 0:
if (!(device->device.version > LAST_KNOWN_DEVICE_VERSION))
if (!((device->device.version>>16) > LAST_KNOWN_DEVICE_MAJOR_VERSION))
{
AddDevice(device);
}
break;
case 1:
if (!(device->device.version > LAST_KNOWN_DEVICE_VERSION))
if (!((device->device.version>>16) > LAST_KNOWN_DEVICE_MAJOR_VERSION))
{
RemoveDevice(device);
}
......@@ -216,7 +216,7 @@ static _kernel_oserror *GetInitialDevices(void)
struct mixer_device *device;
e = _swix(OS_Hardware, _INR(0,1)|_IN(8)|_OUTR(1,2),
(LAST_KNOWN_DEVICE_VERSION << 16) | HALDeviceType_Audio | HALDeviceAudio_Mixer,
(LAST_KNOWN_DEVICE_MAJOR_VERSION << 16) | HALDeviceType_Audio | HALDeviceAudio_Mixer,
r1,
4,
&r1,
......@@ -376,17 +376,27 @@ static _kernel_oserror *ExamineMixerSWI(_kernel_swi_regs *r)
if (e) return e;
uint32_t nchannels = system->device->nchannels;
uint32_t to_do = r->r[2] / sizeof (struct mixer_device_channel_features);
uint32_t block_size = sizeof (struct mixer_device_channel_features);
if (system->device->device.version > 0)
block_size += sizeof (struct mixer_device_channel_limits);
uint32_t to_do = r->r[2] / block_size;
if (to_do > nchannels) to_do = nchannels;
r->r[2] -= nchannels * sizeof (struct mixer_device_channel_features);
r->r[3] = sizeof (struct mixer_device_channel_features);
r->r[2] -= nchannels * block_size;
r->r[3] = block_size;
r->r[4] = to_do;
struct mixer_device_channel_features *ptr = (struct mixer_device_channel_features *) r->r[1];
uint8_t *ptr = (uint8_t *) r->r[1];
for (uint32_t c = 0; c < to_do; c++)
{
*ptr++ = system->device->GetFeatures(system->device, c);
*((struct mixer_device_channel_features *) ptr) = system->device->GetFeatures(system->device, c);
ptr += sizeof(struct mixer_device_channel_features);
if(system->device->device.version > 0)
{
system->device->GetMixLimits(system->device, c, (struct mixer_device_channel_limits *) ptr);
ptr += sizeof(struct mixer_device_channel_limits);
}
}
return e;
......
......@@ -37,6 +37,13 @@ struct mixer_device_channel_state
int32_t gain;
};
struct mixer_device_channel_limits
{
int32_t mingain;
int32_t maxgain;
int32_t step;
};
struct mixer_device
{
struct device device;
......@@ -45,6 +52,7 @@ struct mixer_device
struct mixer_device_channel_features (*GetFeatures)(struct mixer_device *, uint32_t channel);
void (*SetMix)(struct mixer_device *, uint32_t channel, struct mixer_device_channel_state state);
__value_in_regs struct mixer_device_channel_state (*GetMix)(struct mixer_device *, uint32_t channel);
void (*GetMixLimits)(struct mixer_device *, uint32_t channel, struct mixer_device_channel_limits *); /* API 0.1 extension */
};
enum
......
......@@ -34,6 +34,8 @@ HALDevice_MixerGetFeatures # 4
HALDevice_MixerSetMix # 4
HALDevice_MixerGetMix # 4
HALDevice_Mixer_Size * :INDEX: @
HALDevice_MixerGetMixLimits # 4 ; API 0.1 and above
HALDevice_Mixer_Size_0_1 * :INDEX: @
MixerFeaturesFlag_Fixed * 1 :SHL: 0
MixerFeaturesFlag_Mono * 1 :SHL: 1
......
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