Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
D
device_xiaomi_sm8350-common
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
LMODroid-Devices
device_xiaomi_sm8350-common
Commits
5ae87ffe
Commit
5ae87ffe
authored
3 years ago
by
Arian
Browse files
Options
Downloads
Patches
Plain Diff
sm8350-common: vibratoreffect: Read vibration effects fifo data from vendor
Change-Id: I58c74f01d75e8616fdb03c27e3dc4c4df6838faa
parent
b9612a44
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
vibrator/effect/Android.bp
+1
-0
1 addition, 0 deletions
vibrator/effect/Android.bp
vibrator/effect/effect.cpp
+87
-26
87 additions, 26 deletions
vibrator/effect/effect.cpp
with
88 additions
and
26 deletions
vibrator/effect/Android.bp
+
1
−
0
View file @
5ae87ffe
...
...
@@ -8,6 +8,7 @@ cc_library_shared {
srcs: ["effect.cpp"],
shared_libs: [
"libcutils",
"liblog",
"libutils",
],
export_include_dirs: ["."]
...
...
This diff is collapsed.
Click to expand it.
vibrator/effect/effect.cpp
+
87
−
26
View file @
5ae87ffe
/*
* Copyright (c) 2020, The Linux Foundation. All rights reserved.
* Copyright (C) 2022 The LineageOS Project
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
...
...
@@ -27,50 +28,110 @@
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#
include
"
effect
.h
"
#
define LOG_TAG "libxiaomivibrator
effect"
#define ARRAY_SIZE(a) (sizeof(a) / sizeof(*(a)))
#include
<iostream>
#include
<fstream>
#include
<log/log.h>
#include
<sys/stat.h>
/* ~170 HZ sine waveform */
static
const
int8_t
effect_0
[]
=
{
17
,
34
,
50
,
65
,
79
,
92
,
103
,
112
,
119
,
124
,
127
,
127
,
126
,
122
,
116
,
108
,
98
,
86
,
73
,
58
,
42
,
26
,
9
,
-
8
,
-
25
,
-
41
,
-
57
,
-
72
,
-
85
,
-
97
,
-
108
,
-
116
,
-
122
,
-
126
,
-
127
,
-
127
,
-
125
,
-
120
,
-
113
,
-
104
,
-
93
,
-
80
,
-
66
,
-
51
,
-
35
,
-
18
,
-
1
,
};
#include
"effect.h"
static
const
int8_t
effect_1
[]
=
{
-
1
,
-
18
,
-
35
,
-
51
,
-
66
,
-
80
,
-
93
,
-
104
,
-
113
,
-
120
,
-
125
,
-
127
,
-
127
,
-
126
,
-
122
,
-
116
,
-
108
,
-
97
,
-
85
,
-
72
,
-
57
,
-
41
,
-
25
,
-
8
,
9
,
26
,
42
,
58
,
73
,
86
,
98
,
108
,
116
,
122
,
126
,
127
,
127
,
124
,
119
,
112
,
103
,
92
,
79
,
65
,
50
,
34
,
17
,
};
#define ARRAY_SIZE(a) (sizeof(a) / sizeof(*(a)))
static
const
struct
effect_stream
effects
[]
=
{
static
struct
effect_stream
effects
[]
=
{
{
.
effect_id
=
0
,
.
data
=
effect_
0
,
.
length
=
ARRAY_SIZE
(
effect_0
)
,
.
play_rate_hz
=
8
000
,
.
data
=
0
,
.
length
=
0
,
.
play_rate_hz
=
24
000
,
},
{
.
effect_id
=
1
,
.
data
=
effect_1
,
.
length
=
ARRAY_SIZE
(
effect_1
),
.
play_rate_hz
=
8000
,
.
data
=
0
,
.
length
=
0
,
.
play_rate_hz
=
24000
,
},
{
.
effect_id
=
2
,
.
data
=
0
,
.
length
=
0
,
.
play_rate_hz
=
24000
,
},
{
.
effect_id
=
3
,
.
data
=
0
,
.
length
=
0
,
.
play_rate_hz
=
24000
,
},
{
.
effect_id
=
4
,
.
data
=
0
,
.
length
=
0
,
.
play_rate_hz
=
24000
,
},
{
.
effect_id
=
5
,
.
data
=
0
,
.
length
=
0
,
.
play_rate_hz
=
24000
,
},
};
// Array containing the paths to fifo data in vendor.
// The position in the array must match the effect id.
static
const
std
::
string
fifo_data_paths
[]
=
{
"/vendor/firmware/seq_bin_wav1.bin"
,
"/vendor/firmware/seq_bin_wav2.bin"
,
"/vendor/firmware/seq_bin_wav3.bin"
,
"/vendor/firmware/seq_bin_wav4.bin"
,
"/vendor/firmware/seq_bin_wav5.bin"
,
"/vendor/firmware/seq_bin_wav6.bin"
,
};
// Function to parse custom fifo data from vendor
int
parse_custom_data
(
effect_stream
*
effect
)
{
const
char
*
path
=
fifo_data_paths
[
effect
->
effect_id
].
c_str
();
std
::
ifstream
data
;
struct
stat
file_stat
;
int
rc
=
0
;
ALOGI
(
"Parsing custom fifo data for effect %d from path %s"
,
effect
->
effect_id
,
path
);
rc
=
stat
(
path
,
&
file_stat
);
if
(
!
rc
)
{
effect
->
length
=
file_stat
.
st_size
;
}
else
{
ALOGE
(
"Could not open %s"
,
path
);
return
rc
;
}
// Create a persistent 8-bit int array which contains the fifo data, one
// slot of the array contains one byte of the fifo data from vendor.
int8_t
*
custom_data
=
new
int8_t
[
effect
->
length
];
data
.
open
(
path
,
std
::
ios
::
in
|
std
::
ios
::
binary
);
data
.
read
(
reinterpret_cast
<
char
*>
(
custom_data
),
effect
->
length
);
data
.
close
();
effect
->
data
=
custom_data
;
return
rc
;
}
const
struct
effect_stream
*
get_effect_stream
(
uint32_t
effect_id
)
{
int
i
;
for
(
i
=
0
;
i
<
ARRAY_SIZE
(
effects
);
i
++
)
{
if
(
effect_id
==
effects
[
i
].
effect_id
)
if
(
effect_id
==
effects
[
i
].
effect_id
)
{
if
(
effects
[
i
].
length
==
0
&&
parse_custom_data
(
&
effects
[
i
]))
{
ALOGE
(
"Could not get custom_data for effect %d"
,
effects
[
i
].
effect_id
);
return
NULL
;
}
return
&
effects
[
i
];
}
}
return
NULL
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment