Skip to content

Commit

Permalink
Add ES8323/ES8388 codec driver (#12)
Browse files Browse the repository at this point in the history
* Add ES8323/ES8388 codec driver
  • Loading branch information
coolstar authored Nov 24, 2023
1 parent 40b5574 commit ecb5424
Show file tree
Hide file tree
Showing 12 changed files with 1,902 additions and 0 deletions.
8 changes: 8 additions & 0 deletions build/RockchipDrivers.sln
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "rk3xgpio", "..\drivers\gpio
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "pl330dma", "..\drivers\dma\pl330dma\pl330.vcxproj", "{58434B4F-EE73-4D1E-A78D-9FEC5CEC83C7}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "es8323", "..\drivers\audio\codecs\es8323\es8323.vcxproj", "{15D34676-980D-4406-8C05-AB95AA5B43CA}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|ARM64 = Debug|ARM64
Expand Down Expand Up @@ -41,6 +43,12 @@ Global
{58434B4F-EE73-4D1E-A78D-9FEC5CEC83C7}.Release|ARM64.ActiveCfg = Release|ARM64
{58434B4F-EE73-4D1E-A78D-9FEC5CEC83C7}.Release|ARM64.Build.0 = Release|ARM64
{58434B4F-EE73-4D1E-A78D-9FEC5CEC83C7}.Release|ARM64.Deploy.0 = Release|ARM64
{15D34676-980D-4406-8C05-AB95AA5B43CA}.Debug|ARM64.ActiveCfg = Debug|ARM64
{15D34676-980D-4406-8C05-AB95AA5B43CA}.Debug|ARM64.Build.0 = Debug|ARM64
{15D34676-980D-4406-8C05-AB95AA5B43CA}.Debug|ARM64.Deploy.0 = Debug|ARM64
{15D34676-980D-4406-8C05-AB95AA5B43CA}.Release|ARM64.ActiveCfg = Release|ARM64
{15D34676-980D-4406-8C05-AB95AA5B43CA}.Release|ARM64.Build.0 = Release|ARM64
{15D34676-980D-4406-8C05-AB95AA5B43CA}.Release|ARM64.Deploy.0 = Release|ARM64
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
13 changes: 13 additions & 0 deletions drivers/audio/codecs/es8323/LICENSE.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
Copyright 2023 CoolStar

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
8 changes: 8 additions & 0 deletions drivers/audio/codecs/es8323/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# es8323
Everest 8323 I2C Codec driver

Supports:
* 3.5mm output
* 3.5mm input

Tested on Orange Pi 5
98 changes: 98 additions & 0 deletions drivers/audio/codecs/es8323/driver.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
#if !defined(_ES8323_H_)
#define _ES8323_H_

#pragma warning(disable:4200) // suppress nameless struct/union warning
#pragma warning(disable:4201) // suppress nameless struct/union warning
#pragma warning(disable:4214) // suppress bit field types other than int warning
#include <initguid.h>
#include <wdm.h>

#pragma warning(default:4200)
#pragma warning(default:4201)
#pragma warning(default:4214)
#include <wdf.h>

#pragma warning(disable:4201) // suppress nameless struct/union warning
#pragma warning(disable:4214) // suppress bit field types other than int warning
#include <hidport.h>

#include "es8323.h"
#include "spb.h"

//
// String definitions
//

#define DRIVERNAME "es8323.sys: "

#define ES8323_POOL_TAG (ULONG) '8323'
#define ES8323_HARDWARE_IDS L"CoolStar\\ES8323\0\0"
#define ES8323_HARDWARE_IDS_LENGTH sizeof(ES8323_HARDWARE_IDS)

#define NTDEVICE_NAME_STRING L"\\Device\\ES8323"
#define SYMBOLIC_NAME_STRING L"\\DosDevices\\ES8323"

#define true 1
#define false 0

typedef struct _ES8323_CONTEXT
{

//
// Handle back to the WDFDEVICE
//

WDFDEVICE FxDevice;

WDFQUEUE ReportQueue;

SPB_CONTEXT I2CContext;

BOOLEAN ConnectInterrupt;

WDFINTERRUPT Interrupt;

} ES8323_CONTEXT, *PES8323_CONTEXT;

WDF_DECLARE_CONTEXT_TYPE_WITH_NAME(ES8323_CONTEXT, GetDeviceContext)

//
// Function definitions
//

DRIVER_INITIALIZE DriverEntry;

EVT_WDF_DRIVER_UNLOAD Es8323DriverUnload;

EVT_WDF_DRIVER_DEVICE_ADD Es8323EvtDeviceAdd;

EVT_WDFDEVICE_WDM_IRP_PREPROCESS Es8323EvtWdmPreprocessMnQueryId;

EVT_WDF_IO_QUEUE_IO_INTERNAL_DEVICE_CONTROL Es8323EvtInternalDeviceControl;

//
// Helper macros
//

#define DEBUG_LEVEL_ERROR 1
#define DEBUG_LEVEL_INFO 2
#define DEBUG_LEVEL_VERBOSE 3

#define DBG_INIT 1
#define DBG_PNP 2
#define DBG_IOCTL 4

#if 0
#define Es8323Print(dbglevel, dbgcatagory, fmt, ...) { \
if (Es8323DebugLevel >= dbglevel && \
(Es8323DebugCatagories && dbgcatagory)) \
{ \
DbgPrint(DRIVERNAME); \
DbgPrint(fmt, __VA_ARGS__); \
} \
}
#else
#define Es8323Print(dbglevel, fmt, ...) { \
}
#endif
#endif
Loading

0 comments on commit ecb5424

Please sign in to comment.