2016-03-21 20:43:03 +01:00
|
|
|
#include "Emu/Cell/PPUModule.h"
|
2018-03-21 10:02:23 +01:00
|
|
|
#include "Emu/IdManager.h"
|
|
|
|
|
#include "Emu/RSX/rsx_utils.h"
|
2025-04-08 18:46:57 +02:00
|
|
|
#include "Emu/system_config.h"
|
|
|
|
|
#include "stdafx.h"
|
|
|
|
|
#include "util/StrUtil.h"
|
2015-08-01 18:14:49 +02:00
|
|
|
|
|
|
|
|
#include "cellAudioIn.h"
|
|
|
|
|
#include "cellAudioOut.h"
|
2025-04-08 18:46:57 +02:00
|
|
|
#include "cellMic.h"
|
2015-08-01 18:14:49 +02:00
|
|
|
#include "cellVideoOut.h"
|
2014-09-28 17:21:45 +02:00
|
|
|
|
2023-03-03 14:59:43 +01:00
|
|
|
#include <optional>
|
|
|
|
|
|
2018-08-25 14:39:00 +02:00
|
|
|
LOG_CHANNEL(cellAvconfExt);
|
2014-09-28 17:21:45 +02:00
|
|
|
|
2025-04-05 21:50:45 +02:00
|
|
|
template <>
|
2019-11-15 20:15:00 +01:00
|
|
|
void fmt_class_string<CellAudioInError>::format(std::string& out, u64 arg)
|
|
|
|
|
{
|
|
|
|
|
format_enum(out, arg, [](auto error)
|
|
|
|
|
{
|
2025-04-05 21:50:45 +02:00
|
|
|
switch (error)
|
|
|
|
|
{
|
|
|
|
|
STR_CASE(CELL_AUDIO_IN_ERROR_NOT_IMPLEMENTED);
|
|
|
|
|
STR_CASE(CELL_AUDIO_IN_ERROR_ILLEGAL_CONFIGURATION);
|
|
|
|
|
STR_CASE(CELL_AUDIO_IN_ERROR_ILLEGAL_PARAMETER);
|
|
|
|
|
STR_CASE(CELL_AUDIO_IN_ERROR_PARAMETER_OUT_OF_RANGE);
|
|
|
|
|
STR_CASE(CELL_AUDIO_IN_ERROR_DEVICE_NOT_FOUND);
|
|
|
|
|
STR_CASE(CELL_AUDIO_IN_ERROR_UNSUPPORTED_AUDIO_IN);
|
|
|
|
|
STR_CASE(CELL_AUDIO_IN_ERROR_UNSUPPORTED_SOUND_MODE);
|
|
|
|
|
STR_CASE(CELL_AUDIO_IN_ERROR_CONDITION_BUSY);
|
|
|
|
|
}
|
2019-11-15 20:15:00 +01:00
|
|
|
|
2025-04-05 21:50:45 +02:00
|
|
|
return unknown;
|
|
|
|
|
});
|
2019-11-15 20:15:00 +01:00
|
|
|
}
|
|
|
|
|
|
2018-12-20 23:36:56 +01:00
|
|
|
struct avconf_manager
|
|
|
|
|
{
|
2023-03-03 14:59:43 +01:00
|
|
|
shared_mutex mutex;
|
2018-12-20 23:36:56 +01:00
|
|
|
std::vector<CellAudioInDeviceInfo> devices;
|
2025-04-08 18:46:57 +02:00
|
|
|
CellAudioInDeviceMode inDeviceMode =
|
|
|
|
|
CELL_AUDIO_IN_SINGLE_DEVICE_MODE; // TODO: use somewhere
|
2018-12-20 23:36:56 +01:00
|
|
|
|
2023-03-03 14:59:43 +01:00
|
|
|
void copy_device_info(u32 num, vm::ptr<CellAudioInDeviceInfo> info) const;
|
2025-04-08 18:46:57 +02:00
|
|
|
std::optional<CellAudioInDeviceInfo>
|
|
|
|
|
get_device_info(vm::cptr<char> name) const;
|
2021-03-02 17:22:39 +01:00
|
|
|
|
2018-12-20 23:36:56 +01:00
|
|
|
avconf_manager();
|
2021-03-02 17:22:39 +01:00
|
|
|
|
|
|
|
|
avconf_manager(const avconf_manager&) = delete;
|
|
|
|
|
|
|
|
|
|
avconf_manager& operator=(const avconf_manager&) = delete;
|
2018-12-20 23:36:56 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
avconf_manager::avconf_manager()
|
|
|
|
|
{
|
|
|
|
|
u32 curindex = 0;
|
|
|
|
|
|
2025-04-08 18:46:57 +02:00
|
|
|
const std::vector<std::string> mic_list =
|
|
|
|
|
fmt::split(g_cfg.audio.microphone_devices.to_string(), {"@@@"});
|
2023-03-03 14:59:43 +01:00
|
|
|
|
2020-02-26 21:13:54 +01:00
|
|
|
if (!mic_list.empty())
|
2018-12-20 23:36:56 +01:00
|
|
|
{
|
|
|
|
|
switch (g_cfg.audio.microphone_type)
|
|
|
|
|
{
|
|
|
|
|
case microphone_handler::standard:
|
|
|
|
|
for (u32 index = 0; index < mic_list.size(); index++)
|
|
|
|
|
{
|
|
|
|
|
devices.emplace_back();
|
|
|
|
|
|
2025-04-05 21:50:45 +02:00
|
|
|
devices[curindex].portType = CELL_AUDIO_IN_PORT_USB;
|
|
|
|
|
devices[curindex].availableModeCount = 1;
|
|
|
|
|
devices[curindex].state = CELL_AUDIO_IN_DEVICE_STATE_AVAILABLE;
|
|
|
|
|
devices[curindex].deviceId = 0xE11CC0DE + curindex;
|
|
|
|
|
devices[curindex].type = 0xC0DEE11C;
|
2025-04-08 18:46:57 +02:00
|
|
|
devices[curindex].availableModes[0].type =
|
|
|
|
|
CELL_AUDIO_IN_CODING_TYPE_LPCM;
|
2018-12-20 23:36:56 +01:00
|
|
|
devices[curindex].availableModes[0].channel = CELL_AUDIO_IN_CHNUM_2;
|
2025-04-08 18:46:57 +02:00
|
|
|
devices[curindex].availableModes[0].fs =
|
|
|
|
|
CELL_AUDIO_IN_FS_8KHZ | CELL_AUDIO_IN_FS_12KHZ |
|
|
|
|
|
CELL_AUDIO_IN_FS_16KHZ | CELL_AUDIO_IN_FS_24KHZ |
|
|
|
|
|
CELL_AUDIO_IN_FS_32KHZ | CELL_AUDIO_IN_FS_48KHZ;
|
2025-04-05 21:50:45 +02:00
|
|
|
devices[curindex].deviceNumber = curindex;
|
2020-02-18 12:34:23 +01:00
|
|
|
strcpy_trunc(devices[curindex].name, mic_list[index]);
|
2018-12-20 23:36:56 +01:00
|
|
|
|
|
|
|
|
curindex++;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case microphone_handler::real_singstar:
|
|
|
|
|
case microphone_handler::singstar:
|
|
|
|
|
// Only one device for singstar device
|
|
|
|
|
devices.emplace_back();
|
|
|
|
|
|
2025-04-05 21:50:45 +02:00
|
|
|
devices[curindex].portType = CELL_AUDIO_IN_PORT_USB;
|
|
|
|
|
devices[curindex].availableModeCount = 1;
|
|
|
|
|
devices[curindex].state = CELL_AUDIO_IN_DEVICE_STATE_AVAILABLE;
|
|
|
|
|
devices[curindex].deviceId = 0x00000001;
|
|
|
|
|
devices[curindex].type = 0x14150000;
|
|
|
|
|
devices[curindex].availableModes[0].type = CELL_AUDIO_IN_CODING_TYPE_LPCM;
|
2018-12-20 23:36:56 +01:00
|
|
|
devices[curindex].availableModes[0].channel = CELL_AUDIO_IN_CHNUM_2;
|
2025-04-08 18:46:57 +02:00
|
|
|
devices[curindex].availableModes[0].fs =
|
|
|
|
|
CELL_AUDIO_IN_FS_8KHZ | CELL_AUDIO_IN_FS_12KHZ |
|
|
|
|
|
CELL_AUDIO_IN_FS_16KHZ | CELL_AUDIO_IN_FS_24KHZ |
|
|
|
|
|
CELL_AUDIO_IN_FS_32KHZ | CELL_AUDIO_IN_FS_48KHZ;
|
2025-04-05 21:50:45 +02:00
|
|
|
devices[curindex].deviceNumber = curindex;
|
2020-02-18 12:34:23 +01:00
|
|
|
strcpy_trunc(devices[curindex].name, mic_list[0]);
|
2018-12-20 23:36:56 +01:00
|
|
|
|
|
|
|
|
curindex++;
|
|
|
|
|
break;
|
|
|
|
|
case microphone_handler::rocksmith:
|
|
|
|
|
devices.emplace_back();
|
|
|
|
|
|
2025-04-05 21:50:45 +02:00
|
|
|
devices[curindex].portType = CELL_AUDIO_IN_PORT_USB;
|
|
|
|
|
devices[curindex].availableModeCount = 1;
|
|
|
|
|
devices[curindex].state = CELL_AUDIO_IN_DEVICE_STATE_AVAILABLE;
|
2025-04-08 18:46:57 +02:00
|
|
|
devices[curindex].deviceId =
|
|
|
|
|
0x12BA00FF; // Specific to rocksmith usb input
|
2025-04-05 21:50:45 +02:00
|
|
|
devices[curindex].type = 0xC0DE73C4;
|
|
|
|
|
devices[curindex].availableModes[0].type = CELL_AUDIO_IN_CODING_TYPE_LPCM;
|
2018-12-20 23:36:56 +01:00
|
|
|
devices[curindex].availableModes[0].channel = CELL_AUDIO_IN_CHNUM_1;
|
2025-04-08 18:46:57 +02:00
|
|
|
devices[curindex].availableModes[0].fs =
|
|
|
|
|
CELL_AUDIO_IN_FS_8KHZ | CELL_AUDIO_IN_FS_12KHZ |
|
|
|
|
|
CELL_AUDIO_IN_FS_16KHZ | CELL_AUDIO_IN_FS_24KHZ |
|
|
|
|
|
CELL_AUDIO_IN_FS_32KHZ | CELL_AUDIO_IN_FS_48KHZ;
|
2025-04-05 21:50:45 +02:00
|
|
|
devices[curindex].deviceNumber = curindex;
|
2020-02-18 12:34:23 +01:00
|
|
|
strcpy_trunc(devices[curindex].name, mic_list[0]);
|
2018-12-20 23:36:56 +01:00
|
|
|
|
|
|
|
|
curindex++;
|
|
|
|
|
break;
|
2021-04-09 21:12:47 +02:00
|
|
|
case microphone_handler::null:
|
2025-04-08 18:46:57 +02:00
|
|
|
default:
|
|
|
|
|
break;
|
2018-12-20 23:36:56 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (g_cfg.io.camera != camera_handler::null)
|
|
|
|
|
{
|
|
|
|
|
devices.emplace_back();
|
|
|
|
|
|
2025-04-05 21:50:45 +02:00
|
|
|
devices[curindex].portType = CELL_AUDIO_IN_PORT_USB;
|
|
|
|
|
devices[curindex].availableModeCount = 1;
|
|
|
|
|
devices[curindex].state = CELL_AUDIO_IN_DEVICE_STATE_AVAILABLE;
|
|
|
|
|
devices[curindex].deviceId = 0xDEADBEEF;
|
|
|
|
|
devices[curindex].type = 0xBEEFDEAD;
|
|
|
|
|
devices[curindex].availableModes[0].type = CELL_AUDIO_IN_CODING_TYPE_LPCM;
|
2018-12-20 23:36:56 +01:00
|
|
|
devices[curindex].availableModes[0].channel = CELL_AUDIO_IN_CHNUM_NONE;
|
2025-04-08 18:46:57 +02:00
|
|
|
devices[curindex].availableModes[0].fs =
|
|
|
|
|
CELL_AUDIO_IN_FS_8KHZ | CELL_AUDIO_IN_FS_12KHZ |
|
|
|
|
|
CELL_AUDIO_IN_FS_16KHZ | CELL_AUDIO_IN_FS_24KHZ |
|
|
|
|
|
CELL_AUDIO_IN_FS_32KHZ | CELL_AUDIO_IN_FS_48KHZ;
|
2025-04-05 21:50:45 +02:00
|
|
|
devices[curindex].deviceNumber = curindex;
|
2020-02-18 12:34:23 +01:00
|
|
|
strcpy_trunc(devices[curindex].name, "USB Camera");
|
2018-12-20 23:36:56 +01:00
|
|
|
|
|
|
|
|
curindex++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2025-04-08 18:46:57 +02:00
|
|
|
void avconf_manager::copy_device_info(
|
|
|
|
|
u32 num, vm::ptr<CellAudioInDeviceInfo> info) const
|
2018-12-20 23:36:56 +01:00
|
|
|
{
|
|
|
|
|
memset(info.get_ptr(), 0, sizeof(CellAudioInDeviceInfo));
|
2023-03-03 14:59:43 +01:00
|
|
|
ensure(num < devices.size());
|
|
|
|
|
*info = devices[num];
|
|
|
|
|
}
|
2018-12-20 23:36:56 +01:00
|
|
|
|
2025-04-08 18:46:57 +02:00
|
|
|
std::optional<CellAudioInDeviceInfo>
|
|
|
|
|
avconf_manager::get_device_info(vm::cptr<char> name) const
|
2023-03-03 14:59:43 +01:00
|
|
|
{
|
|
|
|
|
for (const CellAudioInDeviceInfo& device : devices)
|
|
|
|
|
{
|
2023-03-25 09:11:22 +01:00
|
|
|
if (strncmp(device.name, name.get_ptr(), sizeof(device.name)) == 0)
|
2023-03-03 14:59:43 +01:00
|
|
|
{
|
|
|
|
|
return device;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return std::nullopt;
|
2018-12-20 23:36:56 +01:00
|
|
|
}
|
|
|
|
|
|
2019-11-15 20:15:00 +01:00
|
|
|
error_code cellAudioOutUnregisterDevice(u32 deviceNumber)
|
2015-07-30 00:30:13 +02:00
|
|
|
{
|
2025-04-08 18:46:57 +02:00
|
|
|
cellAvconfExt.todo("cellAudioOutUnregisterDevice(deviceNumber=0x%x)",
|
|
|
|
|
deviceNumber);
|
2017-03-12 03:20:37 +01:00
|
|
|
return CELL_OK;
|
2015-07-30 00:30:13 +02:00
|
|
|
}
|
|
|
|
|
|
2025-04-08 18:46:57 +02:00
|
|
|
error_code cellAudioOutGetDeviceInfo2(u32 deviceNumber, u32 deviceIndex,
|
|
|
|
|
vm::ptr<CellAudioOutDeviceInfo2> info)
|
2015-07-30 00:30:13 +02:00
|
|
|
{
|
2025-04-08 18:46:57 +02:00
|
|
|
cellAvconfExt.todo("cellAudioOutGetDeviceInfo2(deviceNumber=0x%x, "
|
|
|
|
|
"deviceIndex=0x%x, info=*0x%x)",
|
|
|
|
|
deviceNumber, deviceIndex, info);
|
2022-06-21 22:13:51 +02:00
|
|
|
|
|
|
|
|
if (deviceIndex != 0 || !info)
|
|
|
|
|
{
|
|
|
|
|
return CELL_AUDIO_OUT_ERROR_ILLEGAL_PARAMETER;
|
|
|
|
|
}
|
|
|
|
|
|
2017-03-12 03:20:37 +01:00
|
|
|
return CELL_OK;
|
2015-07-30 00:30:13 +02:00
|
|
|
}
|
|
|
|
|
|
2022-06-21 22:13:51 +02:00
|
|
|
error_code cellVideoOutSetXVColor(u32 unk1, u32 unk2, u32 unk3)
|
2015-07-30 00:30:13 +02:00
|
|
|
{
|
2025-04-08 18:46:57 +02:00
|
|
|
cellAvconfExt.todo("cellVideoOutSetXVColor(unk1=0x%x, unk2=0x%x, unk3=0x%x)",
|
|
|
|
|
unk1, unk2, unk3);
|
2022-06-21 22:13:51 +02:00
|
|
|
|
|
|
|
|
if (unk1 != 0)
|
|
|
|
|
{
|
|
|
|
|
return CELL_VIDEO_OUT_ERROR_NOT_IMPLEMENTED;
|
|
|
|
|
}
|
|
|
|
|
|
2017-03-12 03:20:37 +01:00
|
|
|
return CELL_OK;
|
2015-07-30 00:30:13 +02:00
|
|
|
}
|
|
|
|
|
|
2022-06-21 22:13:51 +02:00
|
|
|
error_code cellVideoOutSetupDisplay(u32 videoOut)
|
2015-07-30 00:30:13 +02:00
|
|
|
{
|
2022-06-21 22:13:51 +02:00
|
|
|
cellAvconfExt.todo("cellVideoOutSetupDisplay(videoOut=%d)", videoOut);
|
|
|
|
|
|
|
|
|
|
if (videoOut != CELL_VIDEO_OUT_SECONDARY)
|
|
|
|
|
{
|
|
|
|
|
return CELL_VIDEO_OUT_ERROR_UNSUPPORTED_VIDEO_OUT;
|
|
|
|
|
}
|
|
|
|
|
|
2017-03-12 03:20:37 +01:00
|
|
|
return CELL_OK;
|
2015-07-30 00:30:13 +02:00
|
|
|
}
|
|
|
|
|
|
2025-04-08 18:46:57 +02:00
|
|
|
error_code cellAudioInGetDeviceInfo(u32 deviceNumber, u32 deviceIndex,
|
|
|
|
|
vm::ptr<CellAudioInDeviceInfo> info)
|
2015-07-30 00:30:13 +02:00
|
|
|
{
|
2025-04-08 18:46:57 +02:00
|
|
|
cellAvconfExt.trace("cellAudioInGetDeviceInfo(deviceNumber=0x%x, "
|
|
|
|
|
"deviceIndex=0x%x, info=*0x%x)",
|
|
|
|
|
deviceNumber, deviceIndex, info);
|
2018-12-20 23:36:56 +01:00
|
|
|
|
2020-01-22 22:45:47 +01:00
|
|
|
if (deviceIndex != 0 || !info)
|
|
|
|
|
{
|
|
|
|
|
return CELL_AUDIO_IN_ERROR_ILLEGAL_PARAMETER;
|
|
|
|
|
}
|
|
|
|
|
|
2021-03-02 12:59:19 +01:00
|
|
|
auto& av_manager = g_fxo->get<avconf_manager>();
|
2023-03-03 14:59:43 +01:00
|
|
|
std::lock_guard lock(av_manager.mutex);
|
2018-12-20 23:36:56 +01:00
|
|
|
|
2021-03-02 12:59:19 +01:00
|
|
|
if (deviceNumber >= av_manager.devices.size())
|
2018-12-20 23:36:56 +01:00
|
|
|
return CELL_AUDIO_OUT_ERROR_DEVICE_NOT_FOUND;
|
|
|
|
|
|
2021-03-02 12:59:19 +01:00
|
|
|
av_manager.copy_device_info(deviceNumber, info);
|
2018-12-20 23:36:56 +01:00
|
|
|
|
2017-03-12 03:20:37 +01:00
|
|
|
return CELL_OK;
|
2015-07-30 00:30:13 +02:00
|
|
|
}
|
|
|
|
|
|
2025-04-08 18:46:57 +02:00
|
|
|
error_code cellVideoOutConvertCursorColor(u32 videoOut,
|
|
|
|
|
s32 displaybuffer_format, f32 gamma,
|
|
|
|
|
s32 source_buffer_format,
|
|
|
|
|
vm::ptr<void> src_addr,
|
|
|
|
|
vm::ptr<u32> dest_addr, s32 num)
|
2014-09-28 17:21:45 +02:00
|
|
|
{
|
2025-04-08 18:46:57 +02:00
|
|
|
cellAvconfExt.todo(
|
|
|
|
|
"cellVideoOutConvertCursorColor(videoOut=%d, displaybuffer_format=0x%x, "
|
|
|
|
|
"gamma=0x%x, source_buffer_format=0x%x, src_addr=*0x%x, dest_addr=*0x%x, "
|
|
|
|
|
"num=0x%x)",
|
|
|
|
|
videoOut, displaybuffer_format, gamma, source_buffer_format, src_addr,
|
|
|
|
|
dest_addr, num);
|
2022-06-21 22:13:51 +02:00
|
|
|
|
|
|
|
|
if (!dest_addr || num == 0)
|
|
|
|
|
{
|
|
|
|
|
return CELL_VIDEO_OUT_ERROR_ILLEGAL_PARAMETER;
|
|
|
|
|
}
|
|
|
|
|
|
2025-04-08 18:46:57 +02:00
|
|
|
if (displaybuffer_format >
|
|
|
|
|
CELL_VIDEO_OUT_BUFFER_COLOR_FORMAT_R16G16B16X16_FLOAT ||
|
|
|
|
|
src_addr)
|
2022-06-21 22:13:51 +02:00
|
|
|
{
|
|
|
|
|
return CELL_VIDEO_OUT_ERROR_PARAMETER_OUT_OF_RANGE;
|
|
|
|
|
}
|
|
|
|
|
|
2025-04-08 18:46:57 +02:00
|
|
|
if (displaybuffer_format <
|
|
|
|
|
CELL_VIDEO_OUT_BUFFER_COLOR_FORMAT_R16G16B16X16_FLOAT)
|
2022-06-21 22:13:51 +02:00
|
|
|
{
|
|
|
|
|
if (gamma < 0.8f || gamma > 1.2f)
|
|
|
|
|
{
|
|
|
|
|
return CELL_VIDEO_OUT_ERROR_PARAMETER_OUT_OF_RANGE;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2025-04-08 18:46:57 +02:00
|
|
|
error_code cellVideoOutGetConvertCursorColorInfo(
|
|
|
|
|
vm::ptr<u8> rgbOutputRange); // Forward declaration
|
2022-06-21 22:13:51 +02:00
|
|
|
|
|
|
|
|
vm::var<u8> rgbOutputRange;
|
2025-04-08 18:46:57 +02:00
|
|
|
if (error_code error =
|
|
|
|
|
cellVideoOutGetConvertCursorColorInfo(rgbOutputRange))
|
2022-06-21 22:13:51 +02:00
|
|
|
{
|
|
|
|
|
return error;
|
|
|
|
|
}
|
|
|
|
|
|
2017-03-12 03:20:37 +01:00
|
|
|
return CELL_OK;
|
2015-07-30 00:30:13 +02:00
|
|
|
}
|
|
|
|
|
|
2019-11-15 20:15:00 +01:00
|
|
|
error_code cellVideoOutGetGamma(u32 videoOut, vm::ptr<f32> gamma)
|
2015-07-30 00:30:13 +02:00
|
|
|
{
|
2025-04-08 18:46:57 +02:00
|
|
|
cellAvconfExt.warning("cellVideoOutGetGamma(videoOut=%d, gamma=*0x%x)",
|
|
|
|
|
videoOut, gamma);
|
2015-08-10 13:09:57 +02:00
|
|
|
|
2021-11-11 22:23:45 +01:00
|
|
|
if (!gamma)
|
|
|
|
|
{
|
|
|
|
|
return CELL_VIDEO_OUT_ERROR_ILLEGAL_PARAMETER;
|
|
|
|
|
}
|
|
|
|
|
|
2015-08-10 13:09:57 +02:00
|
|
|
if (videoOut != CELL_VIDEO_OUT_PRIMARY)
|
|
|
|
|
{
|
|
|
|
|
return CELL_VIDEO_OUT_ERROR_UNSUPPORTED_VIDEO_OUT;
|
|
|
|
|
}
|
|
|
|
|
|
2021-11-10 22:18:46 +01:00
|
|
|
const auto& conf = g_fxo->get<rsx::avconf>();
|
2021-03-02 12:59:19 +01:00
|
|
|
|
|
|
|
|
*gamma = conf.gamma;
|
2015-08-10 13:09:57 +02:00
|
|
|
|
|
|
|
|
return CELL_OK;
|
2015-07-30 00:30:13 +02:00
|
|
|
}
|
|
|
|
|
|
2025-04-08 18:46:57 +02:00
|
|
|
error_code
|
|
|
|
|
cellAudioInGetAvailableDeviceInfo(u32 count,
|
|
|
|
|
vm::ptr<CellAudioInDeviceInfo> device_info)
|
2015-07-30 00:30:13 +02:00
|
|
|
{
|
2025-04-08 18:46:57 +02:00
|
|
|
cellAvconfExt.trace("cellAudioInGetAvailableDeviceInfo(count=%d, info=*0x%x)",
|
|
|
|
|
count, device_info);
|
2018-12-20 23:36:56 +01:00
|
|
|
|
2020-01-22 22:36:14 +01:00
|
|
|
if (count > 16 || !device_info)
|
2018-12-20 23:36:56 +01:00
|
|
|
{
|
|
|
|
|
return CELL_AUDIO_IN_ERROR_ILLEGAL_PARAMETER;
|
|
|
|
|
}
|
|
|
|
|
|
2021-03-02 12:59:19 +01:00
|
|
|
auto& av_manager = g_fxo->get<avconf_manager>();
|
2023-03-03 14:59:43 +01:00
|
|
|
std::lock_guard lock(av_manager.mutex);
|
2018-12-20 23:36:56 +01:00
|
|
|
|
2021-03-02 12:59:19 +01:00
|
|
|
u32 num_devices_returned = std::min<u32>(count, ::size32(av_manager.devices));
|
2018-12-20 23:36:56 +01:00
|
|
|
|
|
|
|
|
for (u32 index = 0; index < num_devices_returned; index++)
|
|
|
|
|
{
|
2021-03-02 12:59:19 +01:00
|
|
|
av_manager.copy_device_info(index, device_info + index);
|
2018-12-20 23:36:56 +01:00
|
|
|
}
|
|
|
|
|
|
2023-03-03 14:59:43 +01:00
|
|
|
CellAudioInDeviceInfo disconnected_device{};
|
|
|
|
|
disconnected_device.state = CELL_AUDIO_OUT_DEVICE_STATE_UNAVAILABLE;
|
|
|
|
|
disconnected_device.deviceNumber = 0xff;
|
|
|
|
|
|
|
|
|
|
for (u32 index = num_devices_returned; index < count; index++)
|
|
|
|
|
{
|
|
|
|
|
device_info[index] = disconnected_device;
|
|
|
|
|
}
|
|
|
|
|
|
2019-12-01 18:14:58 +01:00
|
|
|
return not_an_error(num_devices_returned);
|
2015-07-30 00:30:13 +02:00
|
|
|
}
|
|
|
|
|
|
2025-04-08 18:46:57 +02:00
|
|
|
error_code
|
|
|
|
|
cellAudioOutGetAvailableDeviceInfo(u32 count,
|
|
|
|
|
vm::ptr<CellAudioOutDeviceInfo2> info)
|
2015-07-30 00:30:13 +02:00
|
|
|
{
|
2025-04-08 18:46:57 +02:00
|
|
|
cellAvconfExt.todo(
|
|
|
|
|
"cellAudioOutGetAvailableDeviceInfo(count=0x%x, info=*0x%x)", count,
|
|
|
|
|
info);
|
2022-06-21 22:13:51 +02:00
|
|
|
|
|
|
|
|
if (count > 16 || !info)
|
|
|
|
|
{
|
|
|
|
|
return CELL_AUDIO_OUT_ERROR_ILLEGAL_PARAMETER;
|
|
|
|
|
}
|
|
|
|
|
|
2019-11-15 20:15:00 +01:00
|
|
|
return not_an_error(0); // number of available devices
|
2015-07-30 00:30:13 +02:00
|
|
|
}
|
|
|
|
|
|
2019-11-15 20:15:00 +01:00
|
|
|
error_code cellVideoOutSetGamma(u32 videoOut, f32 gamma)
|
2015-07-30 00:30:13 +02:00
|
|
|
{
|
2025-04-08 18:46:57 +02:00
|
|
|
cellAvconfExt.trace("cellVideoOutSetGamma(videoOut=%d, gamma=%f)", videoOut,
|
|
|
|
|
gamma);
|
2015-08-10 13:09:57 +02:00
|
|
|
|
2022-06-21 22:13:51 +02:00
|
|
|
if (gamma < 0.8f || gamma > 1.2f)
|
2015-08-10 13:09:57 +02:00
|
|
|
{
|
2022-06-21 22:13:51 +02:00
|
|
|
return CELL_VIDEO_OUT_ERROR_PARAMETER_OUT_OF_RANGE;
|
2015-08-10 13:09:57 +02:00
|
|
|
}
|
|
|
|
|
|
2019-11-15 20:56:26 +01:00
|
|
|
if (videoOut != CELL_VIDEO_OUT_PRIMARY)
|
2015-08-10 13:09:57 +02:00
|
|
|
{
|
2019-11-15 20:56:26 +01:00
|
|
|
return CELL_VIDEO_OUT_ERROR_UNSUPPORTED_VIDEO_OUT;
|
2015-08-10 13:09:57 +02:00
|
|
|
}
|
|
|
|
|
|
2021-03-02 12:59:19 +01:00
|
|
|
auto& conf = g_fxo->get<rsx::avconf>();
|
|
|
|
|
conf.gamma = gamma;
|
2015-08-10 13:09:57 +02:00
|
|
|
|
|
|
|
|
return CELL_OK;
|
2015-07-30 00:30:13 +02:00
|
|
|
}
|
|
|
|
|
|
2025-04-08 18:46:57 +02:00
|
|
|
error_code
|
|
|
|
|
cellAudioOutRegisterDevice(u64 deviceType, vm::cptr<char> name,
|
|
|
|
|
vm::ptr<CellAudioOutRegistrationOption> option,
|
|
|
|
|
vm::ptr<CellAudioOutDeviceConfiguration> config)
|
2015-07-30 00:30:13 +02:00
|
|
|
{
|
2025-04-08 18:46:57 +02:00
|
|
|
cellAvconfExt.todo("cellAudioOutRegisterDevice(deviceType=0x%llx, name=%s, "
|
|
|
|
|
"option=*0x%x, config=*0x%x)",
|
|
|
|
|
deviceType, name, option, config);
|
2022-06-21 22:13:51 +02:00
|
|
|
|
|
|
|
|
if (option || !name)
|
|
|
|
|
{
|
|
|
|
|
return CELL_AUDIO_IN_ERROR_ILLEGAL_PARAMETER; // Strange choice for an error
|
|
|
|
|
}
|
|
|
|
|
|
2019-11-15 20:15:00 +01:00
|
|
|
return not_an_error(0); // device number
|
2015-07-30 00:30:13 +02:00
|
|
|
}
|
|
|
|
|
|
2019-11-15 20:15:00 +01:00
|
|
|
error_code cellAudioOutSetDeviceMode(u32 deviceMode)
|
2015-07-30 00:30:13 +02:00
|
|
|
{
|
2017-08-09 18:40:11 +02:00
|
|
|
cellAvconfExt.todo("cellAudioOutSetDeviceMode(deviceMode=0x%x)", deviceMode);
|
2022-06-21 22:13:51 +02:00
|
|
|
|
|
|
|
|
if (deviceMode > CELL_AUDIO_OUT_MULTI_DEVICE_MODE_2)
|
|
|
|
|
{
|
|
|
|
|
return CELL_AUDIO_OUT_ERROR_ILLEGAL_PARAMETER;
|
|
|
|
|
}
|
|
|
|
|
|
2017-03-12 03:20:37 +01:00
|
|
|
return CELL_OK;
|
2015-07-30 00:30:13 +02:00
|
|
|
}
|
|
|
|
|
|
2019-11-15 20:15:00 +01:00
|
|
|
error_code cellAudioInSetDeviceMode(u32 deviceMode)
|
2015-07-30 00:30:13 +02:00
|
|
|
{
|
2017-08-09 18:40:11 +02:00
|
|
|
cellAvconfExt.todo("cellAudioInSetDeviceMode(deviceMode=0x%x)", deviceMode);
|
2022-06-21 22:13:51 +02:00
|
|
|
|
|
|
|
|
switch (deviceMode)
|
|
|
|
|
{
|
|
|
|
|
case CELL_AUDIO_IN_SINGLE_DEVICE_MODE:
|
|
|
|
|
case CELL_AUDIO_IN_MULTI_DEVICE_MODE:
|
|
|
|
|
case CELL_AUDIO_IN_MULTI_DEVICE_MODE_2:
|
|
|
|
|
case CELL_AUDIO_IN_MULTI_DEVICE_MODE_10:
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
return CELL_AUDIO_IN_ERROR_ILLEGAL_PARAMETER;
|
|
|
|
|
}
|
|
|
|
|
|
2023-03-03 14:59:43 +01:00
|
|
|
auto& av_manager = g_fxo->get<avconf_manager>();
|
|
|
|
|
std::lock_guard lock(av_manager.mutex);
|
|
|
|
|
|
|
|
|
|
av_manager.inDeviceMode = static_cast<CellAudioInDeviceMode>(deviceMode);
|
|
|
|
|
|
2017-03-12 03:20:37 +01:00
|
|
|
return CELL_OK;
|
2015-07-30 00:30:13 +02:00
|
|
|
}
|
|
|
|
|
|
2025-04-08 18:46:57 +02:00
|
|
|
error_code
|
|
|
|
|
cellAudioInRegisterDevice(u64 deviceType, vm::cptr<char> name,
|
|
|
|
|
vm::ptr<CellAudioInRegistrationOption> option,
|
|
|
|
|
vm::ptr<CellAudioInDeviceConfiguration> config)
|
2015-07-30 00:30:13 +02:00
|
|
|
{
|
2025-04-08 18:46:57 +02:00
|
|
|
cellAvconfExt.todo("cellAudioInRegisterDevice(deviceType=0x%llx, name=%s, "
|
|
|
|
|
"option=*0x%x, config=*0x%x)",
|
|
|
|
|
deviceType, name, option, config);
|
2018-12-20 23:36:56 +01:00
|
|
|
|
2025-04-08 18:46:57 +02:00
|
|
|
// option must be null, volume can be 1 (soft) to 5 (loud) (raises question
|
|
|
|
|
// about check for volume = 0)
|
2020-01-22 19:25:54 +01:00
|
|
|
if (option || !config || !name || config->volume > 5)
|
2019-11-15 20:15:00 +01:00
|
|
|
{
|
|
|
|
|
return CELL_AUDIO_IN_ERROR_ILLEGAL_PARAMETER;
|
|
|
|
|
}
|
|
|
|
|
|
2023-03-03 14:59:43 +01:00
|
|
|
auto& av_manager = g_fxo->get<avconf_manager>();
|
|
|
|
|
const std::lock_guard lock(av_manager.mutex);
|
|
|
|
|
|
|
|
|
|
std::optional<CellAudioInDeviceInfo> info = av_manager.get_device_info(name);
|
2023-03-25 09:11:22 +01:00
|
|
|
if (!info || !memchr(info->name, '\0', sizeof(info->name)))
|
2023-03-03 14:59:43 +01:00
|
|
|
{
|
|
|
|
|
// TODO
|
|
|
|
|
return CELL_AUDIO_IN_ERROR_DEVICE_NOT_FOUND;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
auto& mic_thr = g_fxo->get<mic_thread>();
|
|
|
|
|
const std::lock_guard mic_lock(mic_thr.mutex);
|
|
|
|
|
const u32 device_number = mic_thr.register_device(info->name);
|
|
|
|
|
|
|
|
|
|
return not_an_error(device_number);
|
2015-07-30 00:30:13 +02:00
|
|
|
}
|
|
|
|
|
|
2019-11-15 20:15:00 +01:00
|
|
|
error_code cellAudioInUnregisterDevice(u32 deviceNumber)
|
2015-07-30 00:30:13 +02:00
|
|
|
{
|
2025-04-08 18:46:57 +02:00
|
|
|
cellAvconfExt.todo("cellAudioInUnregisterDevice(deviceNumber=0x%x)",
|
|
|
|
|
deviceNumber);
|
2023-03-03 14:59:43 +01:00
|
|
|
|
|
|
|
|
auto& mic_thr = g_fxo->get<mic_thread>();
|
|
|
|
|
const std::lock_guard lock(mic_thr.mutex);
|
|
|
|
|
mic_thr.unregister_device(deviceNumber);
|
|
|
|
|
|
2017-03-12 03:20:37 +01:00
|
|
|
return CELL_OK;
|
2014-09-28 17:21:45 +02:00
|
|
|
}
|
|
|
|
|
|
2019-11-15 20:15:00 +01:00
|
|
|
error_code cellVideoOutGetScreenSize(u32 videoOut, vm::ptr<f32> screenSize)
|
2014-09-28 17:21:45 +02:00
|
|
|
{
|
2025-04-08 18:46:57 +02:00
|
|
|
cellAvconfExt.warning(
|
|
|
|
|
"cellVideoOutGetScreenSize(videoOut=%d, screenSize=*0x%x)", videoOut,
|
|
|
|
|
screenSize);
|
2014-09-28 17:21:45 +02:00
|
|
|
|
2021-11-11 22:23:45 +01:00
|
|
|
if (!screenSize)
|
|
|
|
|
{
|
|
|
|
|
return CELL_VIDEO_OUT_ERROR_ILLEGAL_PARAMETER;
|
|
|
|
|
}
|
|
|
|
|
|
2015-01-02 16:29:57 +01:00
|
|
|
if (videoOut != CELL_VIDEO_OUT_PRIMARY)
|
|
|
|
|
{
|
2014-09-28 17:21:45 +02:00
|
|
|
return CELL_VIDEO_OUT_ERROR_UNSUPPORTED_VIDEO_OUT;
|
2015-01-02 16:29:57 +01:00
|
|
|
}
|
2014-09-28 17:21:45 +02:00
|
|
|
|
2023-04-07 20:08:07 +02:00
|
|
|
if (g_cfg.video.stereo_render_mode != stereo_render_mode_options::disabled)
|
2020-01-07 17:07:09 +01:00
|
|
|
{
|
|
|
|
|
// Return Playstation 3D display value
|
|
|
|
|
// Some games call this function when 3D is enabled
|
|
|
|
|
*screenSize = 24.f;
|
|
|
|
|
return CELL_OK;
|
|
|
|
|
}
|
|
|
|
|
|
2018-12-20 23:36:56 +01:00
|
|
|
// TODO: Use virtual screen size
|
2014-09-28 18:42:37 +02:00
|
|
|
#ifdef _WIN32
|
2018-12-20 23:36:56 +01:00
|
|
|
// HDC screen = GetDC(NULL);
|
2025-04-08 18:46:57 +02:00
|
|
|
// float diagonal = roundf(sqrtf((powf(float(GetDeviceCaps(screen,
|
|
|
|
|
// HORZSIZE)), 2) + powf(float(GetDeviceCaps(screen, VERTSIZE)), 2))) *
|
|
|
|
|
// 0.0393f);
|
2014-09-28 18:42:37 +02:00
|
|
|
#else
|
|
|
|
|
// TODO: Linux implementation, without using wx
|
2025-04-08 18:46:57 +02:00
|
|
|
// float diagonal = roundf(sqrtf((powf(wxGetDisplaySizeMM().GetWidth(), 2) +
|
|
|
|
|
// powf(wxGetDisplaySizeMM().GetHeight(), 2))) * 0.0393f);
|
2014-09-28 18:42:37 +02:00
|
|
|
#endif
|
2014-09-28 17:21:45 +02:00
|
|
|
|
|
|
|
|
return CELL_VIDEO_OUT_ERROR_VALUE_IS_NOT_SET;
|
|
|
|
|
}
|
|
|
|
|
|
2019-11-15 20:15:00 +01:00
|
|
|
error_code cellVideoOutSetCopyControl(u32 videoOut, u32 control)
|
2017-08-09 18:40:56 +02:00
|
|
|
{
|
2025-04-08 18:46:57 +02:00
|
|
|
cellAvconfExt.todo("cellVideoOutSetCopyControl(videoOut=%d, control=0x%x)",
|
|
|
|
|
videoOut, control);
|
2022-06-21 22:13:51 +02:00
|
|
|
|
|
|
|
|
if (control > CELL_VIDEO_OUT_COPY_CONTROL_COPY_NEVER)
|
|
|
|
|
{
|
|
|
|
|
return CELL_VIDEO_OUT_ERROR_ILLEGAL_PARAMETER;
|
|
|
|
|
}
|
|
|
|
|
|
2017-08-09 18:40:56 +02:00
|
|
|
return CELL_OK;
|
|
|
|
|
}
|
|
|
|
|
|
2020-02-22 14:02:45 +01:00
|
|
|
error_code cellVideoOutConfigure2()
|
|
|
|
|
{
|
|
|
|
|
cellAvconfExt.todo("cellVideoOutConfigure2()");
|
2022-06-21 22:13:51 +02:00
|
|
|
|
|
|
|
|
if (false) // TODO
|
|
|
|
|
{
|
|
|
|
|
return CELL_VIDEO_OUT_ERROR_ILLEGAL_PARAMETER;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (false) // TODO
|
|
|
|
|
{
|
|
|
|
|
return CELL_VIDEO_OUT_ERROR_PARAMETER_OUT_OF_RANGE;
|
|
|
|
|
}
|
|
|
|
|
|
2020-02-22 14:02:45 +01:00
|
|
|
return CELL_OK;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
error_code cellAudioOutGetConfiguration2()
|
|
|
|
|
{
|
|
|
|
|
cellAvconfExt.todo("cellAudioOutGetConfiguration2()");
|
2022-06-21 22:13:51 +02:00
|
|
|
|
|
|
|
|
if (false) // TODO
|
|
|
|
|
{
|
|
|
|
|
return CELL_AUDIO_OUT_ERROR_ILLEGAL_PARAMETER;
|
|
|
|
|
}
|
|
|
|
|
|
2020-02-22 14:02:45 +01:00
|
|
|
return CELL_OK;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
error_code cellAudioOutConfigure2()
|
|
|
|
|
{
|
|
|
|
|
cellAvconfExt.todo("cellAudioOutConfigure2()");
|
2022-06-21 22:13:51 +02:00
|
|
|
|
|
|
|
|
if (false) // TODO
|
|
|
|
|
{
|
|
|
|
|
return CELL_AUDIO_OUT_ERROR_ILLEGAL_PARAMETER;
|
|
|
|
|
}
|
|
|
|
|
|
2020-02-22 14:02:45 +01:00
|
|
|
return CELL_OK;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
error_code cellVideoOutGetResolutionAvailability2()
|
|
|
|
|
{
|
|
|
|
|
cellAvconfExt.todo("cellVideoOutGetResolutionAvailability2()");
|
|
|
|
|
return CELL_OK;
|
|
|
|
|
}
|
|
|
|
|
|
2021-03-02 12:59:19 +01:00
|
|
|
DECLARE(ppu_module_manager::cellAvconfExt)("cellSysutilAvconfExt", []()
|
2025-04-05 21:50:45 +02:00
|
|
|
{
|
|
|
|
|
REG_FUNC(cellSysutilAvconfExt, cellAudioOutUnregisterDevice);
|
|
|
|
|
REG_FUNC(cellSysutilAvconfExt, cellAudioOutGetDeviceInfo2);
|
|
|
|
|
REG_FUNC(cellSysutilAvconfExt, cellVideoOutSetXVColor);
|
|
|
|
|
REG_FUNC(cellSysutilAvconfExt, cellVideoOutSetupDisplay);
|
|
|
|
|
REG_FUNC(cellSysutilAvconfExt, cellAudioInGetDeviceInfo);
|
|
|
|
|
REG_FUNC(cellSysutilAvconfExt, cellVideoOutConvertCursorColor);
|
|
|
|
|
REG_FUNC(cellSysutilAvconfExt, cellVideoOutGetGamma);
|
|
|
|
|
REG_FUNC(cellSysutilAvconfExt, cellAudioInGetAvailableDeviceInfo);
|
|
|
|
|
REG_FUNC(cellSysutilAvconfExt, cellAudioOutGetAvailableDeviceInfo);
|
|
|
|
|
REG_FUNC(cellSysutilAvconfExt, cellVideoOutSetGamma);
|
|
|
|
|
REG_FUNC(cellSysutilAvconfExt, cellAudioOutRegisterDevice);
|
|
|
|
|
REG_FUNC(cellSysutilAvconfExt, cellAudioOutSetDeviceMode);
|
|
|
|
|
REG_FUNC(cellSysutilAvconfExt, cellAudioInSetDeviceMode);
|
|
|
|
|
REG_FUNC(cellSysutilAvconfExt, cellAudioInRegisterDevice);
|
|
|
|
|
REG_FUNC(cellSysutilAvconfExt, cellAudioInUnregisterDevice);
|
|
|
|
|
REG_FUNC(cellSysutilAvconfExt, cellVideoOutGetScreenSize);
|
|
|
|
|
REG_FUNC(cellSysutilAvconfExt, cellVideoOutSetCopyControl);
|
|
|
|
|
REG_FUNC(cellSysutilAvconfExt, cellVideoOutConfigure2);
|
|
|
|
|
REG_FUNC(cellSysutilAvconfExt, cellAudioOutGetConfiguration2);
|
|
|
|
|
REG_FUNC(cellSysutilAvconfExt, cellAudioOutConfigure2);
|
|
|
|
|
REG_FUNC(cellSysutilAvconfExt, cellVideoOutGetResolutionAvailability2);
|
|
|
|
|
});
|