hdspm: metering ioctl fixed
PATCH 1/2 hdspm: metering ioctl fixed
Metering didn't work before. I know of no application that used this ioctl before, so I assume it is safe to modify the structure.
diff a/sound/pci/rme9652/hdspm.c b/sound/pci/rme9652/hdspm.c
10a11,13
Quoted 3 lines
* Modified 2009-04-13 for proper metering by Florian Faber
* <[email protected]>
*
82c85,86
< "Remy Bruno <[email protected]>");
---
Quoted 2 lines
"Remy Bruno <[email protected]>, "
"Florian Faber <[email protected]>");
136c140,151
< #define HDSPM_MADI_peakrmsbase 4096 /* 4096-8191 2x64x32Bit Meters */
---
Quoted 5 lines
#define
HDSPM_MADI_INPUT_PEAK4096
#defineHDSPM_MADI_PLAYBACK_PEAK4352
#defineHDSPM_MADI_OUTPUT_PEAK4608
Quoted 7 lines
#define
HDSPM_MADI_INPUT_RMS_L6144
#defineHDSPM_MADI_PLAYBACK_RMS_L6400
#defineHDSPM_MADI_OUTPUT_RMS_L6656#define
HDSPM_MADI_INPUT_RMS_H7168
#defineHDSPM_MADI_PLAYBACK_RMS_H7424
#defineHDSPM_MADI_OUTPUT_RMS_H7680
707c722
< /* maby a madi input (which is taken if sel sync is madi) */
---
Quoted 1 line
/* mayby a madi input (which is taken if sel sync is madi) */
4108a4124,4128
Quoted 5 lines
static inline int
copy_u32_le(void __user *dest, void __iomem *src){ u32 val = readl(src); return copy_to_user(dest, &val, 4); }
4111c4131
< unsigned int cmd, unsigned long arg)
---
Quoted 1 line
unsigned int cmd, unsigned long
__userarg)
4113,4136c4133,4172
< struct hdspm *hdspm = hw->private_data;
< struct hdspm_mixer_ioctl mixer;
< struct hdspm_config_info info;
< struct hdspm_version hdspm_version;
< struct hdspm_peak_rms_ioctl rms;
<
< switch (cmd) {
<
< case SNDRV_HDSPM_IOCTL_GET_PEAK_RMS:
< if (copy_from_user(&rms, (void __user *)arg, sizeof(rms)))
< return -EFAULT;
< /* maybe there is a chance to memorymap in future
< * so dont touch just copy
< */
< if(copy_to_user_fromio((void __user *)rms.peak,
< hdspm->iobase+HDSPM_MADI_peakrmsbase,
< sizeof(struct hdspm_peak_rms)) != 0 )
< return -EFAULT;
<
< break;
<
<
< case SNDRV_HDSPM_IOCTL_GET_CONFIG_INFO:
<
---
Quoted 6 lines
void __user *argp = (void __user *)arg; struct hdspm *hdspm = hw->private_data; struct hdspm_mixer_ioctl mixer; struct hdspm_config_info info; struct hdspm_version hdspm_version; struct hdspm_peak_rms levels;
Quoted 8 lines
long unsigned int s;
int i=0;
switch (cmd) {
case SNDRV_HDSPM_IOCTL_GET_PEAK_RMS:
for (i=0; i<64; i++) {
levels.input_peaks[i] = readl(hdspm->iobase+HDSPM_MADI_INPUT_PEAK+i*4);
Quoted 1 line
levels.playback_peaks[i] = readl(hdspm->iobase
+HDSPM_MADI_PLAYBACK_PEAK+i*4);
Quoted 1 line
levels.output_peaks[i] = readl(hdspm->iobase
+HDSPM_MADI_OUTPUT_PEAK+i*4);
Quoted 1 line
levels.input_rms[i] = (readl(hdspm->iobase
+HDSPM_MADI_INPUT_RMS_H+i*4) << 32) | readl(hdspm->iobase +HDSPM_MADI_INPUT_RMS_L+i*4);
Quoted 1 line
levels.playback_rms[i] = (readl(hdspm->iobase
+HDSPM_MADI_PLAYBACK_RMS_H+i*4) << 32) | readl(hdspm->iobase +HDSPM_MADI_PLAYBACK_RMS_L+i*4);
Quoted 1 line
levels.output_rms[i] = (readl(hdspm->iobase
+HDSPM_MADI_OUTPUT_RMS_H+i*4) << 32) | readl(hdspm->iobase +HDSPM_MADI_OUTPUT_RMS_L+i*4);
Quoted 6 lines
}
if (hdspm->system_sample_rate>96000) {
levels.speed = qs;
} else if (hdspm->system_sample_rate>48000) {
levels.speed = ds;Quoted 8 lines
} else {
levels.speed = ss;
}
levels.status2 = hdspm_read(hdspm, HDSPM_statusRegister2);
s = copy_to_user(argp, &levels, sizeof(struct hdspm_peak_rms));
if (0 != s) {
snd_printk(KERN_ERR "copy_to_user(.., .., %lu): %lu\n",sizeof(struct hdspm_peak_rms), s);
Quoted 7 lines
return -EFAULT; } break;case
SNDRV_HDSPM_IOCTL_GET_CONFIG_INFO:
Flo
Signature · 2 lines
Machines can do the work, so people have time to think. public key 6C002249 x-hkp://wwwkeys.eu.pgp.net
At Tue, 14 Apr 2009 17:47:20 +0200,
Quoted 3 lines · Florian Faber
Metering didn't work before. I know of no application that used this ioctl before, so I assume it is safe to modify the structure.
Thanks for the patch. But, could you make a unified diff instead? If you invoke the diff manually, use -up option.
Also, please give your sign-off. It's mandatory for merging to the upstream. See $LINUX/Documentation/SubmittingPatches for details.
Finally, please run once $LINUX/scripts/checkpatch.pl before submitting the patch. This will tell you possible coding-style issues to fix.
thanks,
Takashi