Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
L
linux
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
linux
Commits
240491e1
Commit
240491e1
authored
Dec 30, 2014
by
Takashi Iwai
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'topic/pcm-params' into for-next
parents
614acf93
757b0376
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
56 additions
and
59 deletions
+56
-59
include/sound/pcm.h
include/sound/pcm.h
+5
-8
include/sound/pcm_params.h
include/sound/pcm_params.h
+48
-48
sound/core/oss/pcm_oss.c
sound/core/oss/pcm_oss.c
+3
-3
No files found.
include/sound/pcm.h
View file @
240491e1
...
...
@@ -94,9 +94,6 @@ struct snd_pcm_ops {
#define SNDRV_PCM_DEVICES 8
#endif
#define SNDRV_PCM_IOCTL1_FALSE ((void *)0)
#define SNDRV_PCM_IOCTL1_TRUE ((void *)1)
#define SNDRV_PCM_IOCTL1_RESET 0
#define SNDRV_PCM_IOCTL1_INFO 1
#define SNDRV_PCM_IOCTL1_CHANNEL_INFO 2
...
...
@@ -857,7 +854,7 @@ static inline unsigned int params_channels(const struct snd_pcm_hw_params *p)
}
/**
* params_
channels
- Get the sample rate from the hw params
* params_
rate
- Get the sample rate from the hw params
* @p: hw params
*/
static
inline
unsigned
int
params_rate
(
const
struct
snd_pcm_hw_params
*
p
)
...
...
@@ -866,7 +863,7 @@ static inline unsigned int params_rate(const struct snd_pcm_hw_params *p)
}
/**
* params_
channels
- Get the period size (in frames) from the hw params
* params_
period_size
- Get the period size (in frames) from the hw params
* @p: hw params
*/
static
inline
unsigned
int
params_period_size
(
const
struct
snd_pcm_hw_params
*
p
)
...
...
@@ -875,7 +872,7 @@ static inline unsigned int params_period_size(const struct snd_pcm_hw_params *p)
}
/**
* params_
channel
s - Get the number of periods from the hw params
* params_
period
s - Get the number of periods from the hw params
* @p: hw params
*/
static
inline
unsigned
int
params_periods
(
const
struct
snd_pcm_hw_params
*
p
)
...
...
@@ -884,7 +881,7 @@ static inline unsigned int params_periods(const struct snd_pcm_hw_params *p)
}
/**
* params_
channels
- Get the buffer size (in frames) from the hw params
* params_
buffer_size
- Get the buffer size (in frames) from the hw params
* @p: hw params
*/
static
inline
unsigned
int
params_buffer_size
(
const
struct
snd_pcm_hw_params
*
p
)
...
...
@@ -893,7 +890,7 @@ static inline unsigned int params_buffer_size(const struct snd_pcm_hw_params *p)
}
/**
* params_
channel
s - Get the buffer size (in bytes) from the hw params
* params_
buffer_byte
s - Get the buffer size (in bytes) from the hw params
* @p: hw params
*/
static
inline
unsigned
int
params_buffer_bytes
(
const
struct
snd_pcm_hw_params
*
p
)
...
...
include/sound/pcm_params.h
View file @
240491e1
...
...
@@ -38,31 +38,6 @@ int snd_pcm_hw_param_value(const struct snd_pcm_hw_params *params,
#define MASK_OFS(i) ((i) >> 5)
#define MASK_BIT(i) (1U << ((i) & 31))
static
inline
unsigned
int
ld2
(
u_int32_t
v
)
{
unsigned
r
=
0
;
if
(
v
>=
0x10000
)
{
v
>>=
16
;
r
+=
16
;
}
if
(
v
>=
0x100
)
{
v
>>=
8
;
r
+=
8
;
}
if
(
v
>=
0x10
)
{
v
>>=
4
;
r
+=
4
;
}
if
(
v
>=
4
)
{
v
>>=
2
;
r
+=
2
;
}
if
(
v
>=
2
)
r
++
;
return
r
;
}
static
inline
size_t
snd_mask_sizeof
(
void
)
{
return
sizeof
(
struct
snd_mask
);
...
...
@@ -92,7 +67,7 @@ static inline unsigned int snd_mask_min(const struct snd_mask *mask)
int
i
;
for
(
i
=
0
;
i
<
SNDRV_MASK_SIZE
;
i
++
)
{
if
(
mask
->
bits
[
i
])
return
ffs
(
mask
->
bits
[
i
])
-
1
+
(
i
<<
5
);
return
__ffs
(
mask
->
bits
[
i
])
+
(
i
<<
5
);
}
return
0
;
}
...
...
@@ -102,7 +77,7 @@ static inline unsigned int snd_mask_max(const struct snd_mask *mask)
int
i
;
for
(
i
=
SNDRV_MASK_SIZE
-
1
;
i
>=
0
;
i
--
)
{
if
(
mask
->
bits
[
i
])
return
ld2
(
mask
->
bits
[
i
])
+
(
i
<<
5
);
return
__fls
(
mask
->
bits
[
i
])
+
(
i
<<
5
);
}
return
0
;
}
...
...
@@ -325,43 +300,68 @@ static inline int snd_interval_eq(const struct snd_interval *i1, const struct sn
i1
->
max
==
i2
->
max
&&
i1
->
openmax
==
i2
->
openmax
;
}
static
inline
unsigned
int
add
(
unsigned
int
a
,
unsigned
int
b
)
/**
* params_access - get the access type from the hw params
* @p: hw params
*/
static
inline
snd_pcm_access_t
params_access
(
const
struct
snd_pcm_hw_params
*
p
)
{
if
(
a
>=
UINT_MAX
-
b
)
return
UINT_MAX
;
return
a
+
b
;
return
(
__force
snd_pcm_access_t
)
snd_mask_min
(
hw_param_mask_c
(
p
,
SNDRV_PCM_HW_PARAM_ACCESS
));
}
static
inline
unsigned
int
sub
(
unsigned
int
a
,
unsigned
int
b
)
/**
* params_format - get the sample format from the hw params
* @p: hw params
*/
static
inline
snd_pcm_format_t
params_format
(
const
struct
snd_pcm_hw_params
*
p
)
{
if
(
a
>
b
)
return
a
-
b
;
return
0
;
return
(
__force
snd_pcm_format_t
)
snd_mask_min
(
hw_param_mask_c
(
p
,
SNDRV_PCM_HW_PARAM_FORMAT
));
}
#define params_access(p) ((__force snd_pcm_access_t)\
snd_mask_min(hw_param_mask_c((p), SNDRV_PCM_HW_PARAM_ACCESS)))
#define params_format(p) ((__force snd_pcm_format_t)\
snd_mask_min(hw_param_mask_c((p), SNDRV_PCM_HW_PARAM_FORMAT)))
#define params_subformat(p) \
snd_mask_min(hw_param_mask_c((p), SNDRV_PCM_HW_PARAM_SUBFORMAT))
/**
* params_subformat - get the sample subformat from the hw params
* @p: hw params
*/
static
inline
snd_pcm_subformat_t
params_subformat
(
const
struct
snd_pcm_hw_params
*
p
)
{
return
(
__force
snd_pcm_subformat_t
)
snd_mask_min
(
hw_param_mask_c
(
p
,
SNDRV_PCM_HW_PARAM_SUBFORMAT
));
}
/**
* params_period_bytes - get the period size (in bytes) from the hw params
* @p: hw params
*/
static
inline
unsigned
int
params_period_bytes
(
const
struct
snd_pcm_hw_params
*
p
)
{
return
(
params_period_size
(
p
)
*
snd_pcm_format_physical_width
(
params_format
(
p
))
*
params_channels
(
p
))
/
8
;
return
hw_param_interval_c
(
p
,
SNDRV_PCM_HW_PARAM_PERIOD_BYTES
)
->
min
;
}
static
inline
int
params_width
(
const
struct
snd_pcm_hw_params
*
p
)
/**
* params_width - get the number of bits of the sample format from the hw params
* @p: hw params
*
* This function returns the number of bits per sample that the selected sample
* format of the hw params has.
*/
static
inline
int
params_width
(
const
struct
snd_pcm_hw_params
*
p
)
{
return
snd_pcm_format_width
(
params_format
(
p
));
}
static
inline
int
params_physical_width
(
const
struct
snd_pcm_hw_params
*
p
)
/*
* params_physical_width - get the storage size of the sample format from the hw params
* @p: hw params
*
* This functions returns the number of bits per sample that the selected sample
* format of the hw params takes up in memory. This will be equal or larger than
* params_width().
*/
static
inline
int
params_physical_width
(
const
struct
snd_pcm_hw_params
*
p
)
{
return
snd_pcm_format_physical_width
(
params_format
(
p
));
}
...
...
sound/core/oss/pcm_oss.c
View file @
240491e1
...
...
@@ -719,7 +719,7 @@ static int snd_pcm_oss_period_size(struct snd_pcm_substream *substream,
oss_buffer_size
=
snd_pcm_plug_client_size
(
substream
,
snd_pcm_hw_param_value_max
(
slave_params
,
SNDRV_PCM_HW_PARAM_BUFFER_SIZE
,
NULL
))
*
oss_frame_size
;
oss_buffer_size
=
1
<<
ld2
(
oss_buffer_size
);
oss_buffer_size
=
rounddown_pow_of_two
(
oss_buffer_size
);
if
(
atomic_read
(
&
substream
->
mmap_count
))
{
if
(
oss_buffer_size
>
runtime
->
oss
.
mmap_bytes
)
oss_buffer_size
=
runtime
->
oss
.
mmap_bytes
;
...
...
@@ -755,14 +755,14 @@ static int snd_pcm_oss_period_size(struct snd_pcm_substream *substream,
min_period_size
=
snd_pcm_plug_client_size
(
substream
,
snd_pcm_hw_param_value_min
(
slave_params
,
SNDRV_PCM_HW_PARAM_PERIOD_SIZE
,
NULL
));
min_period_size
*=
oss_frame_size
;
min_period_size
=
1
<<
(
ld2
(
min_period_size
-
1
)
+
1
);
min_period_size
=
roundup_pow_of_two
(
min_period_size
);
if
(
oss_period_size
<
min_period_size
)
oss_period_size
=
min_period_size
;
max_period_size
=
snd_pcm_plug_client_size
(
substream
,
snd_pcm_hw_param_value_max
(
slave_params
,
SNDRV_PCM_HW_PARAM_PERIOD_SIZE
,
NULL
));
max_period_size
*=
oss_frame_size
;
max_period_size
=
1
<<
ld2
(
max_period_size
);
max_period_size
=
rounddown_pow_of_two
(
max_period_size
);
if
(
oss_period_size
>
max_period_size
)
oss_period_size
=
max_period_size
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment