Hi Dan,

I still unable to resolve my p-sensor issue.

I will tell you the issue once again
=> Receive one MT call
=> Answer the call and put device to close to your ear
=> P-sensor can work and backlight turn off
=> while i am moving phone away from EAR screen is not turned ON.

My p-sensor h/w is capella, due to this reason
=> i took the p-sensor HAL from device/htc/passion-common/
libsensors  /ProximitySensor.cpp
=> I registered my driver with input core [earlier in froyo my driver
doesn't have input core]

P-sensor is working with USB cable, but w/o USB cable screen is not turned
ON when i move the device away from my EAR.

I attach a HAL code, logs for working & non working case.

How to configure my prox driver as support wakeable
interrupt?

Please let me know if you have any inputs on this.
let me know if you have any concerns.

Regards,
Jagan.



On Fri, Apr 29, 2011 at 4:19 PM, DanM <murpd...@gmail.com> wrote:

> Are you sure that the proximity sensor sent the data to the user space
> to wake up the device?
> Are you sure that the proximity driver is configured as a wakeable
> interrupt?
>
> Dan
>
> On Apr 26, 12:51 am, jagan <402ja...@gmail.com> wrote:
> > Dan,
> >
> > Then what is significance of maxRange, resolution w.r.t
> PROXIMITY_THRESHOLD
> > value.
> >
> > When i update the above attributes also,
> > Some times my device is not resumes, while it is away from my ear.
> >
> > Thanks,
> > Jagan
> >
> >
> >
> >
> >
> >
> >
> > On Tue, Apr 26, 2011 at 11:12 AM, JakeLian <jakede1...@hotmail.com>
> wrote:
> > > Dear Dan,
> >
> > > Thanks for your suggestions and responses.
> >
> > > Regarding to my question, I have the solution and implement done.
> >
> > > My solution is writting a function to get sensor output data from
> > > sysfs and report it to the framework, then we can monitor it via some
> > > sensor related apk.
> >
> > > Best Regards
> > > Jake
> >
> > > --
> > > unsubscribe: android-kernel+unsubscr...@googlegroups.com
> > > website:http://groups.google.com/group/android-kernel
>
> --
> unsubscribe: android-kernel+unsubscr...@googlegroups.com
> website: http://groups.google.com/group/android-kernel
>

-- 
unsubscribe: android-kernel+unsubscr...@googlegroups.com
website: http://groups.google.com/group/android-kernel
/*
 * Copyright (C) 2008 The Android Open Source Project
 *
 * 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.
 */

#include <fcntl.h>
#include <errno.h>
#include <math.h>
#include <poll.h>
#include <unistd.h>
#include <dirent.h>
#include <sys/select.h>

#include <linux/my_prox.h>

#include <cutils/log.h>

#include "ProximitySensor.h"

/*****************************************************************************/

ProximitySensor::ProximitySensor()
    : SensorBase(DEVICE_NAME, "proximity"),
      mEnabled(0),
      mInputReader(4),
      mHasPendingEvent(false)
{
    mPendingEvent.version = sizeof(sensors_event_t);
    mPendingEvent.sensor = ID_P;
    mPendingEvent.type = SENSOR_TYPE_PROXIMITY;
    memset(mPendingEvent.data, 0, sizeof(mPendingEvent.data));

    open_device();

    int flags = 0;
    if (!ioctl(dev_fd, MY_IOCTL_GET_ENABLED, &flags)) {
        mEnabled = 1;
        if (flags) {
            setInitialState();
        }
    }
    if (!mEnabled) {
        close_device();
    }
}

ProximitySensor::~ProximitySensor() {
}

int ProximitySensor::setInitialState() {
    struct input_absinfo absinfo;
    if (!ioctl(data_fd, EVIOCGABS(EVENT_TYPE_PROXIMITY), &absinfo)) {
        // make sure to report an event immediately
        mHasPendingEvent = true;
        mPendingEvent.distance = indexToValue(absinfo.value);
    }
    return 0;
}

int ProximitySensor::enable(int32_t, int en) {
    int newState = en ? 1 : 0;
    int err = 0;
    if (newState != mEnabled) {
        if (!mEnabled) {
            open_device();
        }
        int flags = newState;
        err = ioctl(dev_fd, MY_IOCTL_ENABLE, &flags);
        err = err<0 ? -errno : 0;
        LOGE_IF(err, "MY_IOCTL_ENABLE failed (%s)", strerror(-err));
        if (!err) {
            mEnabled = newState;
            if (en) {
                setInitialState();
            }
        }
        if (!mEnabled) {
            close_device();
        }
    }
    return err;
}

bool ProximitySensor::hasPendingEvents() const {
    return mHasPendingEvent;
}

int ProximitySensor::readEvents(sensors_event_t* data, int count)
{
    if (count < 1)
        return -EINVAL;

    if (mHasPendingEvent) {
        mHasPendingEvent = false;
        mPendingEvent.timestamp = getTimestamp();
        *data = mPendingEvent;
        return mEnabled ? 1 : 0;
    }

    ssize_t n = mInputReader.fill(data_fd);
    if (n < 0)
        return n;

    int numEventReceived = 0;
    input_event const* event;

    while (count && mInputReader.readEvent(&event)) {
        int type = event->type;
        if (type == EV_ABS) {
            if (event->code == EVENT_TYPE_PROXIMITY) {
                mPendingEvent.distance = indexToValue(event->value);
            }
        } else if (type == EV_SYN) {
            mPendingEvent.timestamp = timevalToNano(event->time);
            if (mEnabled) {
                *data++ = mPendingEvent;
                count--;
                numEventReceived++;
            }
        } else {
            LOGE("ProximitySensor: unknown event (type=%d, code=%d)",
                    type, event->code);
        }
        mInputReader.next();
    }

    return numEventReceived;
}

float ProximitySensor::indexToValue(size_t index) const
{
    return index * PROXIMITY_THRESHOLD;
}

Attachment: prox_log_jun_13_failed
Description: Binary data

Reply via email to