replace common qcom sources with samsung ones

This commit is contained in:
SaschaNes
2025-08-12 22:13:00 +02:00
parent ba24dcded9
commit 6f7753de11
5682 changed files with 2450203 additions and 103634 deletions

View File

@@ -0,0 +1,133 @@
/*
* Copyright (c) 2021, The Linux Foundation. All rights reserved.
*
* 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, 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 and/or other materials provided
* with the distribution.
* * Neither the name of The Linux Foundation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
* 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.
*/
#include <unistd.h>
#include <stdio.h>
#include <string.h>
#include <signal.h>
#include "PalUsecaseTest.h"
int enable_usecase(int usecaseType)
{
int status =0;
status = OpenAndStartUsecase(usecaseType);
if(status) {
fprintf(stdout, "openAndstartusecase failed\n");
}
return status;
}
int disable_usecase()
{
int status =0;
status = StopAndCloseUsecase();
if(status) {
fprintf(stdout, "openAndstartusecase failed\n");
}
return status;
}
static void sigint_handler(int sig)
{
disable_usecase();
exit(0);
}
int main(int argc, char *argv[])
{
char ch[3];
int status = 0;
unsigned int usecase_id;
int sleep_time = 0;
if (argc < 2 || !strcmp(argv[1], "-help")) {
fprintf(stdout, "Usage for timer : PalTest UsecaseId -T <time>\n"
"Usage for Nontimer: PalTest UsecaseId\n");
return 0;
}
usecase_id = atoi(argv[1]);
if (!usecase_id) {
fprintf(stdout, "Please enter valid usecaseId\n");
return 0;
}
//Handling signals
signal(SIGINT, sigint_handler);
signal(SIGHUP, sigint_handler);
signal(SIGTERM, sigint_handler);
if (argc > 2 && !strcmp(argv[2], "-T")) {
if (argc < 4) {
fprintf(stdout, "Not enough arguments\nUsage : 'PalTest usecaseId -T <time>'\n");
return 0;
}
sleep_time = atoi(argv[3]);
if (!sleep_time) {
fprintf(stdout, "Please enter valid sleep time\n");
return 0;
}
status = enable_usecase(usecase_id);
if (status)
return status;
sleep(sleep_time);
status = disable_usecase();
if (status)
return status;
}
else if (argc == 2) {
fprintf(stdout, "Enter S to start the usecase or C to close the usecase \n");
while (1) {
fgets(ch, 3, stdin);
switch (ch[0]) {
case 'S' :
status = enable_usecase(usecase_id);
if (status) {
return status;
}
break;
case 'C' :
status = disable_usecase();
return status;
break;
default:
fprintf(stdout, "Enter S to start the usecase or C to close the usecase\n");
break;
}
fprintf(stdout, "Enter C to close the usecase\n");
}
}
else
fprintf(stdout, "Usage for timer : PalTest UsecaseId -T <time>\n"
"Usage for Nontimer: PalTest UsecaseId\n");
return status;
}

View File

@@ -0,0 +1,164 @@
/*
* Copyright (c) 2021, The Linux Foundation. All rights reserved.
*
* 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, 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 and/or other materials provided
* with the distribution.
* * Neither the name of The Linux Foundation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
* 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.
*/
#include"PalUsecaseTest.h"
#include <errno.h>
#include <string.h>
static struct pal_stream_attributes *stream_attributes;
static struct pal_device *pal_devices;
static pal_stream_handle_t *pal_stream;
int32_t OpenAndStartUsecase(int usecase_type) {
pal_stream_type_t usecase = (pal_stream_type_t)usecase_type;
int32_t status = 0;
fprintf(stdout, "Enter OpenAndStartUsecase\n");
switch (usecase) {
case PAL_STREAM_ULTRASOUND:
status = setup_usecase_ultrasound();
if (status) {
fprintf(stdout, "Error:Failed to Start UPD\n");
goto exit;
}
fprintf(stdout, "Stream started succefully\n");
break;
default :
fprintf(stdout, "unkown uasecase\n");
status = -EINVAL;
break;
}
exit:
fprintf(stdout, "Exit OpenAndStartUsecase\n");
return status;
}
int32_t StopAndCloseUsecase()
{
int32_t status = 0;
fprintf(stdout, "Enter StopAndCloseUsecase\n");
if (pal_stream) {
status = pal_stream_stop(pal_stream);
if (status) {
fprintf(stdout, "pal_stream_stop failed\n");
}
status = pal_stream_close(pal_stream);
if (status) {
fprintf(stdout, "pal_stream_close failed\n");
}
pal_stream = NULL;
if (stream_attributes)
free(stream_attributes);
if (pal_devices)
free(pal_devices);
}
fprintf(stdout, "Exit StopAndCloseUltrasound\n");
return status;
}
int32_t setup_usecase_ultrasound()
{
int32_t status = 0;
pal_param_payload *param_payload = NULL;
pal_param_upd_event_detection_t payload;
int32_t no_of_devices = 2;
//setting stream attributes
stream_attributes = (struct pal_stream_attributes *)
calloc (1, sizeof(struct pal_stream_attributes));
if (!stream_attributes)
goto exit;
stream_attributes->type = PAL_STREAM_ULTRASOUND;
stream_attributes->direction = PAL_AUDIO_INPUT_OUTPUT;
// setting device attriutes
// device attributes for UPD will be set based on BE used.
pal_devices = (struct pal_device *) calloc(no_of_devices, sizeof(struct pal_device));
status = pal_stream_open(stream_attributes, no_of_devices, pal_devices, 0, NULL,
(pal_stream_callback)&HandleCallbackForUPD, 0, &pal_stream);
if (status) {
fprintf(stdout, "Error:Failed to open UPD stream\n");
goto exit;
}
fprintf(stdout, "Stream Opened succesfully\n");
param_payload = (pal_param_payload *) calloc (1,
sizeof(pal_param_payload) +
sizeof(pal_param_upd_event_detection_t));
if (!param_payload)
goto exit;
payload.register_status = 1;
param_payload->payload_size = sizeof(pal_param_upd_event_detection_t);
memcpy(param_payload->payload, &payload, param_payload->payload_size);
status = pal_stream_set_param(pal_stream, PAL_PARAM_ID_UPD_REGISTER_FOR_EVENTS, param_payload);
if (status) {
fprintf(stdout, "setParams failed");
goto close_stream;
}
status = pal_stream_start(pal_stream);
if (status) {
fprintf(stdout, "Error:Failed to Start UPD");
goto close_stream;
}
goto exit;
close_stream:
pal_stream_close(pal_stream);
pal_stream = NULL;
exit:
if (param_payload)
free(param_payload);
if (stream_attributes) {
free(stream_attributes);
stream_attributes = NULL;
}
return status;
}
static int32_t HandleCallbackForUPD(pal_stream_handle_t *stream_handle,
uint32_t event_id, uint32_t *event_data,
uint32_t event_size, uint64_t cookie)
{
int32_t status = 0;
if (event_id == EVENT_ID_GENERIC_US_DETECTION) {
if (*event_data == 1)
fprintf(stdout, "Event Detected : Near event received\n");
else if (*event_data == 2)
fprintf(stdout, "Event Detected : Far event received\n");
else
fprintf(stdout, "Event Detected : Invalid event %d\n", *event_data);
}
return status;
}

View File

@@ -0,0 +1,45 @@
/*
* Copyright (c) 2021, The Linux Foundation. All rights reserved.
*
* 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, 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 and/or other materials provided
* with the distribution.
* * Neither the name of The Linux Foundation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
* 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.
*/
#ifndef PALUSECASE_TEST_H
#define PALUSECASE_TEST_H
#include <PalApi.h>
#include <PalDefs.h>
#define EVENT_ID_GENERIC_US_DETECTION 0x08001358
int32_t OpenAndStartUsecase(int usecase_type);
int32_t StopAndCloseUsecase();
int32_t setup_usecase_ultrasound();
static int32_t HandleCallbackForUPD(pal_stream_handle_t *stream_handle,
uint32_t event_id, uint32_t *event_data,
uint32_t event_size, uint64_t cookie);
#endif