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
67fe0e2f
Commit
67fe0e2f
authored
3 years ago
by
Cosmin Tanislav
Browse files
Options
Downloads
Patches
Plain Diff
sm8350-common: vibrator: remove unused led vibrator device support
parent
1e781f91
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/Vibrator.cpp
+3
-111
3 additions, 111 deletions
vibrator/Vibrator.cpp
vibrator/include/Vibrator.h
+0
-11
0 additions, 11 deletions
vibrator/include/Vibrator.h
with
3 additions
and
122 deletions
vibrator/Vibrator.cpp
+
3
−
111
View file @
67fe0e2f
...
...
@@ -61,8 +61,6 @@ namespace vibrator {
#define test_bit(bit, array) ((array)[(bit)/8] & (1<<((bit)%8)))
static
const
char
LED_DEVICE
[]
=
"/sys/class/leds/vibrator"
;
InputFFDevice
::
InputFFDevice
()
{
DIR
*
dp
;
...
...
@@ -305,98 +303,9 @@ int InputFFDevice::playEffect(int effectId, EffectStrength es, long *playLengthM
return
play
(
effectId
,
INVALID_VALUE
,
playLengthMs
);
}
LedVibratorDevice
::
LedVibratorDevice
()
{
char
devicename
[
PATH_MAX
];
int
fd
;
mDetected
=
false
;
snprintf
(
devicename
,
sizeof
(
devicename
),
"%s/%s"
,
LED_DEVICE
,
"activate"
);
fd
=
TEMP_FAILURE_RETRY
(
open
(
devicename
,
O_RDWR
));
if
(
fd
<
0
)
{
ALOGE
(
"open %s failed, errno = %d"
,
devicename
,
errno
);
return
;
}
mDetected
=
true
;
}
int
LedVibratorDevice
::
write_value
(
const
char
*
file
,
const
char
*
value
)
{
int
fd
;
int
ret
;
fd
=
TEMP_FAILURE_RETRY
(
open
(
file
,
O_WRONLY
));
if
(
fd
<
0
)
{
ALOGE
(
"open %s failed, errno = %d"
,
file
,
errno
);
return
-
errno
;
}
ret
=
TEMP_FAILURE_RETRY
(
write
(
fd
,
value
,
strlen
(
value
)
+
1
));
if
(
ret
==
-
1
)
{
ret
=
-
errno
;
}
else
if
(
ret
!=
strlen
(
value
)
+
1
)
{
/* even though EAGAIN is an errno value that could be set
by write() in some cases, none of them apply here. So, this return
value can be clearly identified when debugging and suggests the
caller that it may try to call vibrator_on() again */
ret
=
-
EAGAIN
;
}
else
{
ret
=
0
;
}
errno
=
0
;
close
(
fd
);
return
ret
;
}
int
LedVibratorDevice
::
on
(
int32_t
timeoutMs
)
{
char
file
[
PATH_MAX
];
char
value
[
32
];
int
ret
;
snprintf
(
file
,
sizeof
(
file
),
"%s/%s"
,
LED_DEVICE
,
"state"
);
ret
=
write_value
(
file
,
"1"
);
if
(
ret
<
0
)
goto
error
;
snprintf
(
file
,
sizeof
(
file
),
"%s/%s"
,
LED_DEVICE
,
"duration"
);
snprintf
(
value
,
sizeof
(
value
),
"%u
\n
"
,
timeoutMs
);
ret
=
write_value
(
file
,
value
);
if
(
ret
<
0
)
goto
error
;
snprintf
(
file
,
sizeof
(
file
),
"%s/%s"
,
LED_DEVICE
,
"activate"
);
ret
=
write_value
(
file
,
"1"
);
if
(
ret
<
0
)
goto
error
;
return
0
;
error:
ALOGE
(
"Failed to turn on vibrator ret: %d
\n
"
,
ret
);
return
ret
;
}
int
LedVibratorDevice
::
off
()
{
char
file
[
PATH_MAX
];
int
ret
;
snprintf
(
file
,
sizeof
(
file
),
"%s/%s"
,
LED_DEVICE
,
"activate"
);
ret
=
write_value
(
file
,
"0"
);
return
ret
;
}
ndk
::
ScopedAStatus
Vibrator
::
getCapabilities
(
int32_t
*
_aidl_return
)
{
*
_aidl_return
=
IVibrator
::
CAP_ON_CALLBACK
;
if
(
ledVib
.
mDetected
)
{
*
_aidl_return
|=
IVibrator
::
CAP_PERFORM_CALLBACK
;
ALOGD
(
"QTI Vibrator reporting capabilities: %d"
,
*
_aidl_return
);
return
ndk
::
ScopedAStatus
::
ok
();
}
if
(
ff
.
mSupportGain
)
*
_aidl_return
|=
IVibrator
::
CAP_AMPLITUDE_CONTROL
;
if
(
ff
.
mSupportEffects
)
...
...
@@ -412,10 +321,8 @@ ndk::ScopedAStatus Vibrator::off() {
int
ret
;
ALOGD
(
"QTI Vibrator off"
);
if
(
ledVib
.
mDetected
)
ret
=
ledVib
.
off
();
else
ret
=
ff
.
off
();
ret
=
ff
.
off
();
if
(
ret
!=
0
)
return
ndk
::
ScopedAStatus
(
AStatus_fromExceptionCode
(
EX_SERVICE_SPECIFIC
));
...
...
@@ -427,11 +334,8 @@ ndk::ScopedAStatus Vibrator::on(int32_t timeoutMs,
int
ret
;
ALOGD
(
"Vibrator on for timeoutMs: %d"
,
timeoutMs
);
if
(
ledVib
.
mDetected
)
ret
=
ledVib
.
on
(
timeoutMs
);
else
ret
=
ff
.
on
(
timeoutMs
);
ret
=
ff
.
on
(
timeoutMs
);
if
(
ret
!=
0
)
return
ndk
::
ScopedAStatus
(
AStatus_fromExceptionCode
(
EX_SERVICE_SPECIFIC
));
...
...
@@ -453,9 +357,6 @@ ndk::ScopedAStatus Vibrator::perform(Effect effect, EffectStrength es, const std
long
playLengthMs
;
int
ret
;
if
(
ledVib
.
mDetected
)
return
ndk
::
ScopedAStatus
(
AStatus_fromExceptionCode
(
EX_UNSUPPORTED_OPERATION
));
ALOGD
(
"Vibrator perform effect %d"
,
effect
);
if
(
effect
<
Effect
::
CLICK
||
...
...
@@ -483,9 +384,6 @@ ndk::ScopedAStatus Vibrator::perform(Effect effect, EffectStrength es, const std
}
ndk
::
ScopedAStatus
Vibrator
::
getSupportedEffects
(
std
::
vector
<
Effect
>*
_aidl_return
)
{
if
(
ledVib
.
mDetected
)
return
ndk
::
ScopedAStatus
::
ok
();
*
_aidl_return
=
{
Effect
::
CLICK
,
Effect
::
DOUBLE_CLICK
,
Effect
::
TICK
,
Effect
::
THUD
,
Effect
::
POP
,
Effect
::
HEAVY_CLICK
};
...
...
@@ -496,9 +394,6 @@ ndk::ScopedAStatus Vibrator::setAmplitude(float amplitude) {
uint8_t
tmp
;
int
ret
;
if
(
ledVib
.
mDetected
)
return
ndk
::
ScopedAStatus
(
AStatus_fromExceptionCode
(
EX_UNSUPPORTED_OPERATION
));
ALOGD
(
"Vibrator set amplitude: %f"
,
amplitude
);
if
(
amplitude
<=
0.0
f
||
amplitude
>
1.0
f
)
...
...
@@ -516,9 +411,6 @@ ndk::ScopedAStatus Vibrator::setAmplitude(float amplitude) {
}
ndk
::
ScopedAStatus
Vibrator
::
setExternalControl
(
bool
enabled
)
{
if
(
ledVib
.
mDetected
)
return
ndk
::
ScopedAStatus
(
AStatus_fromExceptionCode
(
EX_UNSUPPORTED_OPERATION
));
ALOGD
(
"Vibrator set external control: %d"
,
enabled
);
if
(
!
ff
.
mSupportExternalControl
)
return
ndk
::
ScopedAStatus
(
AStatus_fromExceptionCode
(
EX_UNSUPPORTED_OPERATION
));
...
...
This diff is collapsed.
Click to expand it.
vibrator/include/Vibrator.h
+
0
−
11
View file @
67fe0e2f
...
...
@@ -54,20 +54,9 @@ private:
int16_t
mCurrMagnitude
;
};
class
LedVibratorDevice
{
public:
LedVibratorDevice
();
int
on
(
int32_t
timeoutMs
);
int
off
();
bool
mDetected
;
private:
int
write_value
(
const
char
*
file
,
const
char
*
value
);
};
class
Vibrator
:
public
BnVibrator
{
public:
class
InputFFDevice
ff
;
class
LedVibratorDevice
ledVib
;
ndk
::
ScopedAStatus
getCapabilities
(
int32_t
*
_aidl_return
)
override
;
ndk
::
ScopedAStatus
off
()
override
;
ndk
::
ScopedAStatus
on
(
int32_t
timeoutMs
,
...
...
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