Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix ES8388 vendor & Add I2S Bus driver #14

Merged
merged 5 commits into from
Nov 28, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions build/RockchipDrivers.sln
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "pl330dma", "..\drivers\dma\
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "es8323", "..\drivers\audio\codecs\es8323\es8323.vcxproj", "{15D34676-980D-4406-8C05-AB95AA5B43CA}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "rk3xi2sbus", "..\drivers\audio\rk3xi2sbus\rk3xi2sbus.vcxproj", "{BA95E25D-392E-4BC9-B481-E4D9FB9AFFB4}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|ARM64 = Debug|ARM64
Expand Down Expand Up @@ -49,6 +51,10 @@ Global
{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
{BA95E25D-392E-4BC9-B481-E4D9FB9AFFB4}.Debug|ARM64.ActiveCfg = Debug|ARM64
{BA95E25D-392E-4BC9-B481-E4D9FB9AFFB4}.Release|ARM64.ActiveCfg = Release|ARM64
{BA95E25D-392E-4BC9-B481-E4D9FB9AFFB4}.Release|ARM64.Build.0 = Release|ARM64
{BA95E25D-392E-4BC9-B481-E4D9FB9AFFB4}.Release|ARM64.Deploy.0 = Release|ARM64
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
2 changes: 1 addition & 1 deletion drivers/audio/codecs/es8323/es8323.inx
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ LoadOrderGroup = Base

[Strings]
SPSVCINST_ASSOCSERVICE= 0x00000002
StdMfg = "CoolStar"
StdMfg = "Everest"
DiskId1 = "Everest 8323 Installation Disk #1"
Es8323.DeviceDesc = "Everest 8323 I2S Audio"
Es8388.DeviceDesc = "Everest 8388 I2S Audio"
Expand Down
13 changes: 13 additions & 0 deletions drivers/audio/rk3xi2sbus/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.
4 changes: 4 additions & 0 deletions drivers/audio/rk3xi2sbus/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Rockchip Bus Driver for Rockchip 3xxx I2S

* Exposes I2S resources
* Support accessing topology
105 changes: 105 additions & 0 deletions drivers/audio/rk3xi2sbus/adsp.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
#include "driver.h"
#define ADSP_DECL 1
#include "adsp.h"

NTSTATUS ADSPGetResources(_In_ PVOID _context, _Out_ _PCI_BAR* acpBar, PTPLG_INFO tplgInfo) {
if (!_context)
return STATUS_NO_SUCH_DEVICE;

PPDO_DEVICE_DATA devData = (PPDO_DEVICE_DATA)_context;
if (!devData->FdoContext) {
return STATUS_NO_SUCH_DEVICE;
}

if (acpBar) {
*acpBar = devData->FdoContext->m_MMIO;
}

if (tplgInfo) {
if (devData->FdoContext->rkTplg) {
tplgInfo->rkTplg = devData->FdoContext->rkTplg;
tplgInfo->rkTplgSz = devData->FdoContext->rkTplgSz;
}
}

return STATUS_SUCCESS;
}

NTSTATUS ADSPSetPowerState(_In_ PVOID _context, _In_ DEVICE_POWER_STATE powerState) {
if (!_context)
return STATUS_NO_SUCH_DEVICE;

PPDO_DEVICE_DATA devData = (PPDO_DEVICE_DATA)_context;
if (!devData->FdoContext) {
return STATUS_NO_SUCH_DEVICE;
}

NTSTATUS status = STATUS_SUCCESS;
if (powerState == PowerDeviceD3) {
WdfDeviceResumeIdle(devData->FdoContext->WdfDevice);
} else if (powerState == PowerDeviceD0) {
status = WdfDeviceStopIdle(devData->FdoContext->WdfDevice, TRUE);
}
return status;
}

NTSTATUS ADSPRegisterInterrupt(_In_ PVOID _context, _In_ PADSP_INTERRUPT_CALLBACK callback, _In_ PADSP_DPC_CALLBACK dpcCallback, _In_ PVOID callbackContext) {
if (!_context)
return STATUS_NO_SUCH_DEVICE;

PPDO_DEVICE_DATA devData = (PPDO_DEVICE_DATA)_context;
if (!devData->FdoContext) {
return STATUS_NO_SUCH_DEVICE;
}

devData->FdoContext->dspInterruptCallback = callback;
devData->FdoContext->dspDPCCallback = dpcCallback;
devData->FdoContext->dspInterruptContext = callbackContext;

return STATUS_SUCCESS;
}

NTSTATUS ADSPUnregisterInterrupt(_In_ PVOID _context) {
if (!_context)
return STATUS_NO_SUCH_DEVICE;

PPDO_DEVICE_DATA devData = (PPDO_DEVICE_DATA)_context;
if (!devData->FdoContext) {
return STATUS_NO_SUCH_DEVICE;
}

devData->FdoContext->dspInterruptCallback = NULL;
devData->FdoContext->dspInterruptContext = NULL;
return STATUS_SUCCESS;
}

NTSTATUS ADSPQueueDpcForInterrupt(_In_ PVOID _context) {
if (!_context)
return STATUS_NO_SUCH_DEVICE;

PPDO_DEVICE_DATA devData = (PPDO_DEVICE_DATA)_context;
if (!devData->FdoContext) {
return STATUS_NO_SUCH_DEVICE;
}

BOOL ret = WdfInterruptQueueDpcForIsr(devData->FdoContext->Interrupt);
return ret ? STATUS_SUCCESS : STATUS_UNSUCCESSFUL;
}

RKDSP_BUS_INTERFACE RKDSP_BusInterface(PVOID Context) {
RKDSP_BUS_INTERFACE busInterface;
RtlZeroMemory(&busInterface, sizeof(RKDSP_BUS_INTERFACE));

busInterface.Size = sizeof(RKDSP_BUS_INTERFACE);
busInterface.Version = 1;
busInterface.Context = Context;
busInterface.InterfaceReference = WdfDeviceInterfaceReferenceNoOp;
busInterface.InterfaceDereference = WdfDeviceInterfaceDereferenceNoOp;
busInterface.GetResources = ADSPGetResources;
busInterface.SetDSPPowerState = ADSPSetPowerState;
busInterface.RegisterInterrupt = ADSPRegisterInterrupt;
busInterface.UnregisterInterrupt = ADSPUnregisterInterrupt;
busInterface.QueueDPCForInterrupt = ADSPQueueDpcForInterrupt;

return busInterface;
}
47 changes: 47 additions & 0 deletions drivers/audio/rk3xi2sbus/adsp.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#ifndef __ADSP_INTERFACE
#define __ADSP_INTERFACE
//
// The GUID_RKDSP_BUS_INTERFACE interface GUID
//
// {863DD2AC-5B54-4C57-8487-782F9ADFE8D7}
DEFINE_GUID(GUID_RKDSP_BUS_INTERFACE,
0x863dd2ac, 0x5b54, 0x4c57, 0x84, 0x87, 0x78, 0x2f, 0x9a, 0xdf, 0xe8, 0xd7);

typedef struct _TPLG_INFO {
PVOID rkTplg;
UINT64 rkTplgSz;
} TPLG_INFO, * PTPLG_INFO;

typedef _Must_inspect_result_ NTSTATUS(*PGET_ADSP_RESOURCES) (_In_ PVOID _context, _Out_ _PCI_BAR* acpBar, PTPLG_INFO tplgInfo);
typedef _Must_inspect_result_ NTSTATUS(*PDSP_SET_POWER_STATE) (_In_ PVOID _context, _In_ DEVICE_POWER_STATE newPowerState);
typedef _Must_inspect_result_ BOOL(*PADSP_INTERRUPT_CALLBACK)(PVOID context);
typedef _Must_inspect_result_ VOID(*PADSP_DPC_CALLBACK)(PVOID context);
typedef _Must_inspect_result_ NTSTATUS (*PADSP_QUEUE_DPC)(PVOID context);
typedef _Must_inspect_result_ NTSTATUS(*PREGISTER_ADSP_INTERRUPT) (_In_ PVOID _context, _In_ PADSP_INTERRUPT_CALLBACK callback, _In_ PADSP_DPC_CALLBACK dpcCallback, _In_ PVOID callbackContext);
typedef _Must_inspect_result_ NTSTATUS(*PUNREGISTER_ADSP_INTERRUPT) (_In_ PVOID _context);

typedef struct _RKDSP_BUS_INTERFACE
{
//
// First we define the standard INTERFACE structure ...
//
USHORT Size;
USHORT Version;
PVOID Context;
PINTERFACE_REFERENCE InterfaceReference;
PINTERFACE_DEREFERENCE InterfaceDereference;

//
// Then we expand the structure with the ADSP_BUS_INTERFACE stuff.

PGET_ADSP_RESOURCES GetResources;
PDSP_SET_POWER_STATE SetDSPPowerState;
PREGISTER_ADSP_INTERRUPT RegisterInterrupt;
PUNREGISTER_ADSP_INTERRUPT UnregisterInterrupt;
PADSP_QUEUE_DPC QueueDPCForInterrupt;
} RKDSP_BUS_INTERFACE, * PRKDSP_BUS_INTERFACE;

#ifndef ADSP_DECL
RKDSP_BUS_INTERFACE RKDSP_BusInterface(PVOID Context);
#endif
#endif
Loading
Loading