From fe2d4a0fa3ebcc16de39aa66383d300ccb7fd860 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Duval?= Date: Fri, 8 Nov 2013 19:00:07 +0100 Subject: [PATCH] ac97: added a few codec ids. * minor code cleanup --- src/add-ons/kernel/drivers/audio/ac97/ac97.c | 32 +++++++++++++ src/add-ons/kernel/drivers/audio/ac97/ac97.h | 50 +++++++++++--------- 2 files changed, 59 insertions(+), 23 deletions(-) diff --git a/src/add-ons/kernel/drivers/audio/ac97/ac97.c b/src/add-ons/kernel/drivers/audio/ac97/ac97.c index 37743f43f8..d0a63d6f05 100644 --- a/src/add-ons/kernel/drivers/audio/ac97/ac97.c +++ b/src/add-ons/kernel/drivers/audio/ac97/ac97.c @@ -99,6 +99,7 @@ static void stac9708_init(ac97_dev *dev); static void stac9721_init(ac97_dev *dev); static void stac9744_init(ac97_dev *dev); static void stac9756_init(ac97_dev *dev); +static void stac9758_init(ac97_dev *dev); static void tr28028_init(ac97_dev *dev); static void wm9701_init(ac97_dev *dev); static void wm9703_init(ac97_dev *dev); @@ -136,6 +137,8 @@ codec_table codecs[] = { CODEC_ID_AK4540, 0xffffffff, default_init, "Asahi Kasei AK4540" }, { CODEC_ID_AK4542, 0xffffffff, default_init, "Asahi Kasei AK4542" }, { CODEC_ID_AK4543, 0xffffffff, default_init, "Asahi Kasei AK4543" }, + { 0x414b4d06, 0xffffffff, default_init, "Asahi Kasei AK4544A" }, + { 0x414b4d07, 0xffffffff, default_init, "Asahi Kasei AK4545" }, { 0x414c4300, 0xffffff00, default_init, "Avance Logic (Realtek) ALC100" }, /* 0x4300 = ALC100 */ { 0x414c4320, 0xfffffff0, default_init, "Avance Logic (Realtek) ALC100/ALC100P, RL5383/RL5522" }, { CODEC_ID_ALC201A, 0xfffffff0, default_init, "Avance Logic (Realtek) ALC200/ALC200A, ALC201/ALC201A" }, /* 0x4710 = ALC201A */ @@ -161,6 +164,9 @@ codec_table codecs[] = { 0x43525941, 0xffffffff, default_init, "Cirrus Logic CS4201A" }, { 0x43525951, 0xffffffff, default_init, "Cirrus Logic CS4205A" }, { 0x43525961, 0xffffffff, default_init, "Cirrus Logic CS4291A" }, + { 0x43585421, 0xffffffff, default_init, "HSD11246" }, + { 0x44543031, 0xffffffff, default_init, "DT0398" }, + { 0x454d4328, 0xffffffff, default_init, "EM28028" }, { 0x45838308, 0xffffffff, default_init, "ESS Technology ES1921" }, { 0x49434501, 0xffffffff, default_init, "ICEnsemble ICE1230" }, { 0x49434511, 0xffffffff, default_init, "ICEnsemble ICE1232" }, @@ -175,11 +181,14 @@ codec_table codecs[] = { CODEC_ID_STAC9708,0xffffffff, stac9708_init, "SigmaTel STAC9708/9711" }, { CODEC_ID_STAC9721,0xffffffff, stac9721_init, "SigmaTel STAC9721/9723" }, { CODEC_ID_STAC9744,0xffffffff, stac9744_init, "SigmaTel STAC9744" }, + { CODEC_ID_STAC9750,0xffffffff, default_init, "SigmaTel STAC9750/51" }, { CODEC_ID_STAC9752,0xffffffff, default_init, "SigmaTel STAC9752/53" }, { CODEC_ID_STAC9756,0xffffffff, stac9756_init, "SigmaTel STAC9756/9757" }, + { CODEC_ID_STAC9758,0xffffffff, stac9758_init, "SigmaTel STAC9758/59" }, { CODEC_ID_STAC9766,0xffffffff, default_init, "SigmaTel STAC9766/67" }, { 0x53494c22, 0xffffffff, default_init, "Silicon Laboratory Si3036" }, { 0x53494c23, 0xffffffff, default_init, "Silicon Laboratory Si3038" }, + { 0x53544d02, 0xffffffff, default_init, "ST7597" }, { 0x54524103, 0xffffffff, default_init, "TriTech TR28023" }, { 0x54524106, 0xffffffff, default_init, "TriTech TR28026" }, { 0x54524108, 0xffffffff, tr28028_init, "TriTech TR28028" }, @@ -207,6 +216,7 @@ codec_table codecs[] = { 0x83847600, 0xffffff00, default_init, "SigmaTel" }, { 0x53494c00, 0xffffff00, default_init, "Silicon Laboratory" }, { 0x54524100, 0xffffff00, default_init, "TriTech" }, + { 0x54584e00, 0xffffff00, default_init, "Texas Instruments" }, { 0x56494100, 0xffffff00, default_init, "VIA Technologies" }, { 0x574d4c00, 0xffffff00, default_init, "Wolfson" }, { 0x594d4800, 0xffffff00, default_init, "Yamaha" }, @@ -1039,6 +1049,28 @@ stac9756_init(ac97_dev *dev) } + +void +stac9758_init(ac97_dev *dev) +{ + LOG(("stac9758_init\n")); + + ac97_reg_update_bits(dev, AC97_PAGING, 0xf, 0); + + if (dev->subsystem == 0x107b0601) { + ac97_reg_cached_write(dev, 0x64, 0xfc70); + ac97_reg_cached_write(dev, 0x68, 0x2102); + ac97_reg_cached_write(dev, 0x66, 0x0203); + ac97_reg_cached_write(dev, 0x72, 0x0041); + } else { + ac97_reg_cached_write(dev, 0x64, 0xd794); + ac97_reg_cached_write(dev, 0x68, 0x2001); + ac97_reg_cached_write(dev, 0x66, 0x0201); + ac97_reg_cached_write(dev, 0x72, 0x0040); + } +} + + void tr28028_init(ac97_dev *dev) { diff --git a/src/add-ons/kernel/drivers/audio/ac97/ac97.h b/src/add-ons/kernel/drivers/audio/ac97/ac97.h index 4590833c04..c54996f80b 100644 --- a/src/add-ons/kernel/drivers/audio/ac97/ac97.h +++ b/src/add-ons/kernel/drivers/audio/ac97/ac97.h @@ -5,24 +5,24 @@ * Copyright (c) 2008, Jérôme Duval * * All rights reserved. - * Redistribution and use in source and binary forms, with or without modification, + * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: * - * - Redistributions of source code must retain the above copyright notice, + * - Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * - Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation + * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS - * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * */ @@ -51,7 +51,7 @@ enum AC97_REGISTER { AC97_3D_CONTROL = 0x22, AC97_PAGING = 0x24, AC97_POWERDOWN = 0x26, - + /* Extended audio register set */ AC97_EXTENDED_ID = 0x28, AC97_EXTENDED_STAT_CTRL = 0x2A, @@ -67,14 +67,14 @@ enum AC97_REGISTER { /* Vendor ID */ AC97_VENDOR_ID1 = 0x7C, AC97_VENDOR_ID2 = 0x7E, - + /* Analog Devices */ AC97_AD_JACK_SENSE = 0x72, AC97_AD_SERIAL_CONFIG = 0x74, AC97_AD_MISC_CONTROL = 0x76, AC97_AD_SAMPLE_RATE_0 = 0x78, AC97_AD_SAMPLE_RATE_1 = 0x7a, - + /* Realtek ALC650 */ AC97_ALC650_SPDIF_INPUT_CHAN_STATUS_LO = 0x60, /* only ALC650 Rev. E and later */ AC97_ALC650_SPDIF_INPUT_CHAN_STATUS_HI = 0x62, /* only ALC650 Rev. E and later */ @@ -134,8 +134,10 @@ enum { CODEC_ID_STAC9708 = 0x83847608, // ok, STAC9708/11 CODEC_ID_STAC9721 = 0x83847609, // ok, STAC9721/23 CODEC_ID_STAC9744 = 0x83847644, // ok, STAC9744 + CODEC_ID_STAC9750 = 0x83847650, // ok, STAC9750/51 CODEC_ID_STAC9752 = 0x83847652, // ok, STAC9752/53 CODEC_ID_STAC9756 = 0x83847656, // ok, STAC9756/57 + CODEC_ID_STAC9758 = 0x83847658, // ????, STAC9758/59 CODEC_ID_STAC9766 = 0x83847666, // ok, STAC9766/67 }; @@ -193,19 +195,19 @@ struct ac97_dev { uint16 reg_cache[0x7f]; void * cookie; - + uint32 codec_id; const char * codec_info; const char * codec_3d_stereo_enhancement; - + codec_init init; codec_reg_read reg_read; codec_reg_write reg_write; codec_set_rate set_rate; codec_get_rate get_rate; - uint32 max_vsr; - uint32 min_vsr; + uint32 max_vsr; + uint32 min_vsr; uint32 clock; uint64 capabilities; bool reversed_eamp_polarity; @@ -216,8 +218,9 @@ struct ac97_dev { extern "C" { #endif -void ac97_attach(ac97_dev **dev, codec_reg_read reg_read, codec_reg_write reg_write, void *cookie, - ushort subvendor_id, ushort subsystem_id); +void ac97_attach(ac97_dev **dev, codec_reg_read reg_read, + codec_reg_write reg_write, void *cookie, ushort subvendor_id, + ushort subsystem_id); void ac97_detach(ac97_dev *dev); void ac97_suspend(ac97_dev *dev); void ac97_resume(ac97_dev *dev); @@ -228,7 +231,8 @@ void ac97_reg_uncached_write(ac97_dev *dev, uint8 reg, uint16 value); uint16 ac97_reg_uncached_read(ac97_dev *dev, uint8 reg); bool ac97_reg_update(ac97_dev *dev, uint8 reg, uint16 value); -bool ac97_reg_update_bits(ac97_dev *dev, uint8 reg, uint16 mask, uint16 value); +bool ac97_reg_update_bits(ac97_dev *dev, uint8 reg, uint16 mask, + uint16 value); bool ac97_set_rate(ac97_dev *dev, uint8 reg, uint32 rate); bool ac97_get_rate(ac97_dev *dev, uint8 reg, uint32 *rate); @@ -256,7 +260,7 @@ typedef enum { typedef struct _ac97_source_info { const char *name; ac97_mixer_type type; - + int32 id; uint8 reg; uint16 default_value;