From ba920338cd62ad16678e4941fc7c46017c4e007d Mon Sep 17 00:00:00 2001 From: isaki Date: Sat, 30 Sep 2017 04:07:04 +0000 Subject: [PATCH] Avoid magic numbers and give appropriate names. --- sys/arch/x68k/dev/vs.c | 16 ++++++++++------ sys/arch/x68k/dev/vsvar.h | 10 +++++++--- 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/sys/arch/x68k/dev/vs.c b/sys/arch/x68k/dev/vs.c index ec73b8986134..650603d14ad4 100644 --- a/sys/arch/x68k/dev/vs.c +++ b/sys/arch/x68k/dev/vs.c @@ -1,4 +1,4 @@ -/* $NetBSD: vs.c,v 1.48 2017/09/02 15:40:31 isaki Exp $ */ +/* $NetBSD: vs.c,v 1.49 2017/09/30 04:07:04 isaki Exp $ */ /* * Copyright (c) 2001 Tetsuya Isaki. All rights reserved. @@ -30,7 +30,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: vs.c,v 1.48 2017/09/02 15:40:31 isaki Exp $"); +__KERNEL_RCSID(0, "$NetBSD: vs.c,v 1.49 2017/09/30 04:07:04 isaki Exp $"); #include "audio.h" #include "vs.h" @@ -510,7 +510,8 @@ vs_start_output(void *hdl, void *block, int blksize, void (*intr)(void *), (int)block - (int)KVADDR(vd), blksize); if (sc->sc_active == 0) { - bus_space_write_1(sc->sc_iot, sc->sc_ioh, MSM6258_STAT, 2); + bus_space_write_1(sc->sc_iot, sc->sc_ioh, + MSM6258_CMD, MSM6258_CMD_PLAY_START); sc->sc_active = 1; } @@ -555,7 +556,8 @@ vs_start_input(void *hdl, void *block, int blksize, void (*intr)(void *), (int)block - (int)KVADDR(vd), blksize); if (sc->sc_active == 0) { - bus_space_write_1(sc->sc_iot, sc->sc_ioh, MSM6258_STAT, 4); + bus_space_write_1(sc->sc_iot, sc->sc_ioh, + MSM6258_CMD, MSM6258_CMD_REC_START); sc->sc_active = 1; } @@ -572,7 +574,8 @@ vs_halt_output(void *hdl) if (sc->sc_active) { /* stop ADPCM play */ dmac_abort_xfer(sc->sc_dma_ch->ch_softc, sc->sc_current.xfer); - bus_space_write_1(sc->sc_iot, sc->sc_ioh, MSM6258_STAT, 1); + bus_space_write_1(sc->sc_iot, sc->sc_ioh, + MSM6258_CMD, MSM6258_CMD_STOP); sc->sc_active = 0; } @@ -589,7 +592,8 @@ vs_halt_input(void *hdl) if (sc->sc_active) { /* stop ADPCM recoding */ dmac_abort_xfer(sc->sc_dma_ch->ch_softc, sc->sc_current.xfer); - bus_space_write_1(sc->sc_iot, sc->sc_ioh, MSM6258_STAT, 1); + bus_space_write_1(sc->sc_iot, sc->sc_ioh, + MSM6258_CMD, MSM6258_CMD_STOP); sc->sc_active = 0; } diff --git a/sys/arch/x68k/dev/vsvar.h b/sys/arch/x68k/dev/vsvar.h index 718489a974bf..67e450947cf0 100644 --- a/sys/arch/x68k/dev/vsvar.h +++ b/sys/arch/x68k/dev/vsvar.h @@ -1,4 +1,4 @@ -/* $NetBSD: vsvar.h,v 1.15 2017/09/02 12:52:55 isaki Exp $ */ +/* $NetBSD: vsvar.h,v 1.16 2017/09/30 04:07:04 isaki Exp $ */ /* * Copyright (c) 2001 Tetsuya Isaki. All rights reserved. @@ -59,8 +59,12 @@ #define VS_MAX_BUFSIZE (65536*4) /* XXX: enough? */ /* XXX: msm6258vreg.h */ -#define MSM6258_STAT 0 -#define MSM6258_DATA 1 +#define MSM6258_CMD 0 /* W */ +#define MSM6258_CMD_STOP (0x01) +#define MSM6258_CMD_PLAY_START (0x02) +#define MSM6258_CMD_REC_START (0x04) +#define MSM6258_STAT 0 /* R */ +#define MSM6258_DATA 1 /* R/W */ struct vs_dma { bus_dma_tag_t vd_dmat;