Sat Feb 22 06:28:10 2020 UTC ()
const-ify.  These arguments are no longer written back.


(isaki)
diff -r1.44 -r1.45 src/sys/dev/audio/audio.c

cvs diff -r1.44 -r1.45 src/sys/dev/audio/audio.c (expand / switch to unified diff)

--- src/sys/dev/audio/audio.c 2020/02/22 06:22:46 1.44
+++ src/sys/dev/audio/audio.c 2020/02/22 06:28:10 1.45
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: audio.c,v 1.44 2020/02/22 06:22:46 isaki Exp $ */ 1/* $NetBSD: audio.c,v 1.45 2020/02/22 06:28:10 isaki Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 2008 The NetBSD Foundation, Inc. 4 * Copyright (c) 2008 The NetBSD Foundation, Inc.
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * This code is derived from software contributed to The NetBSD Foundation 7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Andrew Doran. 8 * by Andrew Doran.
9 * 9 *
10 * Redistribution and use in source and binary forms, with or without 10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions 11 * modification, are permitted provided that the following conditions
12 * are met: 12 * are met:
13 * 1. Redistributions of source code must retain the above copyright 13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer. 14 * notice, this list of conditions and the following disclaimer.
@@ -132,27 +132,27 @@ @@ -132,27 +132,27 @@
132 * these may be also called after attach, the thread lock is required. 132 * these may be also called after attach, the thread lock is required.
133 * 133 *
134 * In addition, there is an additional lock. 134 * In addition, there is an additional lock.
135 * 135 *
136 * - track->lock. This is an atomic variable and is similar to the 136 * - track->lock. This is an atomic variable and is similar to the
137 * "interrupt lock". This is one for each track. If any thread context 137 * "interrupt lock". This is one for each track. If any thread context
138 * (and software interrupt context) and hardware interrupt context who 138 * (and software interrupt context) and hardware interrupt context who
139 * want to access some variables on this track, they must acquire this 139 * want to access some variables on this track, they must acquire this
140 * lock before. It protects track's consistency between hardware 140 * lock before. It protects track's consistency between hardware
141 * interrupt context and others. 141 * interrupt context and others.
142 */ 142 */
143 143
144#include <sys/cdefs.h> 144#include <sys/cdefs.h>
145__KERNEL_RCSID(0, "$NetBSD: audio.c,v 1.44 2020/02/22 06:22:46 isaki Exp $"); 145__KERNEL_RCSID(0, "$NetBSD: audio.c,v 1.45 2020/02/22 06:28:10 isaki Exp $");
146 146
147#ifdef _KERNEL_OPT 147#ifdef _KERNEL_OPT
148#include "audio.h" 148#include "audio.h"
149#include "midi.h" 149#include "midi.h"
150#endif 150#endif
151 151
152#if NAUDIO > 0 152#if NAUDIO > 0
153 153
154#include <sys/types.h> 154#include <sys/types.h>
155#include <sys/param.h> 155#include <sys/param.h>
156#include <sys/atomic.h> 156#include <sys/atomic.h>
157#include <sys/audioio.h> 157#include <sys/audioio.h>
158#include <sys/conf.h> 158#include <sys/conf.h>
@@ -537,27 +537,27 @@ static void audio_rintr(void *); @@ -537,27 +537,27 @@ static void audio_rintr(void *);
537 537
538static int audio_query_devinfo(struct audio_softc *, mixer_devinfo_t *); 538static int audio_query_devinfo(struct audio_softc *, mixer_devinfo_t *);
539 539
540static __inline int audio_track_readablebytes(const audio_track_t *); 540static __inline int audio_track_readablebytes(const audio_track_t *);
541static int audio_file_setinfo(struct audio_softc *, audio_file_t *, 541static int audio_file_setinfo(struct audio_softc *, audio_file_t *,
542 const struct audio_info *); 542 const struct audio_info *);
543static int audio_track_setinfo_check(audio_format2_t *, 543static int audio_track_setinfo_check(audio_format2_t *,
544 const struct audio_prinfo *, const audio_format2_t *); 544 const struct audio_prinfo *, const audio_format2_t *);
545static void audio_track_setinfo_water(audio_track_t *, 545static void audio_track_setinfo_water(audio_track_t *,
546 const struct audio_info *); 546 const struct audio_info *);
547static int audio_hw_setinfo(struct audio_softc *, const struct audio_info *, 547static int audio_hw_setinfo(struct audio_softc *, const struct audio_info *,
548 struct audio_info *); 548 struct audio_info *);
549static int audio_hw_set_format(struct audio_softc *, int, 549static int audio_hw_set_format(struct audio_softc *, int,
550 audio_format2_t *, audio_format2_t *, 550 const audio_format2_t *, const audio_format2_t *,
551 audio_filter_reg_t *, audio_filter_reg_t *); 551 audio_filter_reg_t *, audio_filter_reg_t *);
552static int audiogetinfo(struct audio_softc *, struct audio_info *, int, 552static int audiogetinfo(struct audio_softc *, struct audio_info *, int,
553 audio_file_t *); 553 audio_file_t *);
554static bool audio_can_playback(struct audio_softc *); 554static bool audio_can_playback(struct audio_softc *);
555static bool audio_can_capture(struct audio_softc *); 555static bool audio_can_capture(struct audio_softc *);
556static int audio_check_params(audio_format2_t *); 556static int audio_check_params(audio_format2_t *);
557static int audio_mixers_init(struct audio_softc *sc, int, 557static int audio_mixers_init(struct audio_softc *sc, int,
558 const audio_format2_t *, const audio_format2_t *, 558 const audio_format2_t *, const audio_format2_t *,
559 const audio_filter_reg_t *, const audio_filter_reg_t *); 559 const audio_filter_reg_t *, const audio_filter_reg_t *);
560static int audio_select_freq(const struct audio_format *); 560static int audio_select_freq(const struct audio_format *);
561static int audio_hw_probe(struct audio_softc *, int, int *, 561static int audio_hw_probe(struct audio_softc *, int, int *,
562 audio_format2_t *, audio_format2_t *); 562 audio_format2_t *, audio_format2_t *);
563static int audio_hw_probe_fmt(struct audio_softc *, audio_format2_t *, int); 563static int audio_hw_probe_fmt(struct audio_softc *, audio_format2_t *, int);
@@ -6983,35 +6983,34 @@ abort: @@ -6983,35 +6983,34 @@ abort:
6983 return error; 6983 return error;
6984} 6984}
6985 6985
6986/* 6986/*
6987 * Setup the hardware with mixer format phwfmt, rhwfmt. 6987 * Setup the hardware with mixer format phwfmt, rhwfmt.
6988 * The arguments have following restrictions: 6988 * The arguments have following restrictions:
6989 * - setmode is the direction you want to set, AUMODE_PLAY or AUMODE_RECORD, 6989 * - setmode is the direction you want to set, AUMODE_PLAY or AUMODE_RECORD,
6990 * or both. 6990 * or both.
6991 * - phwfmt and rhwfmt must not be NULL regardless of setmode. 6991 * - phwfmt and rhwfmt must not be NULL regardless of setmode.
6992 * - On non-independent devices, phwfmt and rhwfmt must have the same 6992 * - On non-independent devices, phwfmt and rhwfmt must have the same
6993 * parameters. 6993 * parameters.
6994 * - pfil and rfil must be zero-filled. 6994 * - pfil and rfil must be zero-filled.
6995 * If successful, 6995 * If successful,
6996 * - phwfmt, rhwfmt will be overwritten by hardware format. 
6997 * - pfil, rfil will be filled with filter information specified by the 6996 * - pfil, rfil will be filled with filter information specified by the
6998 * hardware driver. 6997 * hardware driver.
6999 * and then returns 0. Otherwise returns errno. 6998 * and then returns 0. Otherwise returns errno.
7000 * Must be called with sc_lock held. 6999 * Must be called with sc_lock held.
7001 */ 7000 */
7002static int 7001static int
7003audio_hw_set_format(struct audio_softc *sc, int setmode, 7002audio_hw_set_format(struct audio_softc *sc, int setmode,
7004 audio_format2_t *phwfmt, audio_format2_t *rhwfmt, 7003 const audio_format2_t *phwfmt, const audio_format2_t *rhwfmt,
7005 audio_filter_reg_t *pfil, audio_filter_reg_t *rfil) 7004 audio_filter_reg_t *pfil, audio_filter_reg_t *rfil)
7006{ 7005{
7007 audio_params_t pp, rp; 7006 audio_params_t pp, rp;
7008 int error; 7007 int error;
7009 7008
7010 KASSERT(mutex_owned(sc->sc_lock)); 7009 KASSERT(mutex_owned(sc->sc_lock));
7011 KASSERT(phwfmt != NULL); 7010 KASSERT(phwfmt != NULL);
7012 KASSERT(rhwfmt != NULL); 7011 KASSERT(rhwfmt != NULL);
7013 7012
7014 pp = format2_to_params(phwfmt); 7013 pp = format2_to_params(phwfmt);
7015 rp = format2_to_params(rhwfmt); 7014 rp = format2_to_params(rhwfmt);
7016 7015
7017 error = sc->hw_if->set_format(sc->hw_hdl, setmode, 7016 error = sc->hw_if->set_format(sc->hw_hdl, setmode,