Send commitlog mailing list submissions to
        [email protected]

To subscribe or unsubscribe via the World Wide Web, visit
        http://lists.openmoko.org/mailman/listinfo/commitlog
or, via email, send a message with subject or body 'help' to
        [EMAIL PROTECTED]

You can reach the person managing the list at
        [EMAIL PROTECTED]

When replying, please edit your Subject line so it is more specific
than "Re: Contents of commitlog digest..."
Today's Topics:

   1. r1963 -
      trunk/src/target/OM-2007/applications/openmoko-dialer/src
      ([EMAIL PROTECTED])
   2. r1964 - in trunk/src/target/gsm: . src/gsmd
      ([EMAIL PROTECTED])
   3. r1965 - in trunk/src/target/OM-2007/openmoko-libs: .
      libmokogsmd ([EMAIL PROTECTED])
   4. r1966 -
      trunk/src/target/OM-2007/applications/openmoko-dialer/src
      ([EMAIL PROTECTED])
   5. r1967 -
      trunk/src/target/OM-2007/artwork/themes/openmoko-standard/gtk-2.0
      ([EMAIL PROTECTED])
   6. r1968 -
      trunk/src/target/OM-2007/applications/openmoko-dialer/src
      ([EMAIL PROTECTED])
   7. r1969 -
      trunk/src/target/OM-2007/applications/openmoko-dialer/src
      ([EMAIL PROTECTED])
   8. r1970 - trunk/src/target/kernel/patches
      ([EMAIL PROTECTED])
--- Begin Message ---
Author: thomas
Date: 2007-05-16 12:04:12 +0200 (Wed, 16 May 2007)
New Revision: 1963

Modified:
   
trunk/src/target/OM-2007/applications/openmoko-dialer/src/dialer-window-history.c
Log:
openmoko-dialer: fix logic


Modified: 
trunk/src/target/OM-2007/applications/openmoko-dialer/src/dialer-window-history.c
===================================================================
--- 
trunk/src/target/OM-2007/applications/openmoko-dialer/src/dialer-window-history.c
   2007-05-16 09:49:34 UTC (rev 1962)
+++ 
trunk/src/target/OM-2007/applications/openmoko-dialer/src/dialer-window-history.c
   2007-05-16 10:04:12 UTC (rev 1963)
@@ -645,7 +645,7 @@
   /* if there aren't any entries in the journal, we don't need to do any more
    * here
    */
-  if (!p_dialer_data->journal || moko_journal_get_nb_entries 
(p_dialer_data->journal))
+  if (!p_dialer_data->journal || !moko_journal_get_nb_entries 
(p_dialer_data->journal))
     return 1;
 
   j_entry = moko_journal_entry_new (VOICE_JOURNAL_ENTRY);
@@ -688,6 +688,8 @@
         HISTORY_ICON_NAME_COLUMN, icon_name,
         HISTORY_DISPLAY_TEXT_COLUMN, display_text,
         -1);
+
+    i++;
   }
 
 




--- End Message ---
--- Begin Message ---
Author: mickey
Date: 2007-05-16 12:32:07 +0200 (Wed, 16 May 2007)
New Revision: 1964

Added:
   trunk/src/target/gsm/ChangeLog
Modified:
   trunk/src/target/gsm/src/gsmd/gsmd.c
Log:
gsmd: power off the phone when gsmd starts up to have a consistent starting 
point


Added: trunk/src/target/gsm/ChangeLog
===================================================================
--- trunk/src/target/gsm/ChangeLog      2007-05-16 10:04:12 UTC (rev 1963)
+++ trunk/src/target/gsm/ChangeLog      2007-05-16 10:32:07 UTC (rev 1964)
@@ -0,0 +1,3 @@
+2007-05-16  Mickey Lauer <[EMAIL PROTECTED]>
+
+* gsmd.c (gsmd_initsettings): always power off gsm to have a sane starting 
point

Modified: trunk/src/target/gsm/src/gsmd/gsmd.c
===================================================================
--- trunk/src/target/gsm/src/gsmd/gsmd.c        2007-05-16 10:04:12 UTC (rev 
1963)
+++ trunk/src/target/gsm/src/gsmd/gsmd.c        2007-05-16 10:32:07 UTC (rev 
1964)
@@ -76,8 +76,8 @@
        rc |= gsmd_simplecmd(gsmd, "AT+CLIP=1");
        /* use +COLP: to indicate COLP */
        rc |= gsmd_simplecmd(gsmd, "AT+COLP=1");
-       /* power on the phone */
-       rc |= gsmd_simplecmd(gsmd, "AT+CFUN=1");
+       /* power off the phone */
+       rc |= gsmd_simplecmd(gsmd, "AT+CFUN=0");
        /* configure message format as PDU mode*/
        /* FIXME: TEXT mode support!! */
        rc |= gsmd_simplecmd(gsmd, "AT+CMGF=0");




--- End Message ---
--- Begin Message ---
Author: thomas
Date: 2007-05-16 12:45:23 +0200 (Wed, 16 May 2007)
New Revision: 1965

Modified:
   trunk/src/target/OM-2007/openmoko-libs/ChangeLog
   trunk/src/target/OM-2007/openmoko-libs/libmokogsmd/moko-gsmd-connection.c
Log:
* libmokogsmd/moko-gsmd-connection.c: (moko_gsmd_connection_voice_dial): Fix 
logic


Modified: trunk/src/target/OM-2007/openmoko-libs/ChangeLog
===================================================================
--- trunk/src/target/OM-2007/openmoko-libs/ChangeLog    2007-05-16 10:32:07 UTC 
(rev 1964)
+++ trunk/src/target/OM-2007/openmoko-libs/ChangeLog    2007-05-16 10:45:23 UTC 
(rev 1965)
@@ -1,3 +1,8 @@
+2007-05-16  Thomas Wood  <[EMAIL PROTECTED]>
+
+       * libmokogsmd/moko-gsmd-connection.c:
+       (moko_gsmd_connection_voice_dial): Fix logic
+
 2007-05-15  Thomas Wood  <[EMAIL PROTECTED]>
 
        * libmokoui/moko-message-dialog.c: (moko_message_dialog_map): Check for

Modified: 
trunk/src/target/OM-2007/openmoko-libs/libmokogsmd/moko-gsmd-connection.c
===================================================================
--- trunk/src/target/OM-2007/openmoko-libs/libmokogsmd/moko-gsmd-connection.c   
2007-05-16 10:32:07 UTC (rev 1964)
+++ trunk/src/target/OM-2007/openmoko-libs/libmokogsmd/moko-gsmd-connection.c   
2007-05-16 10:45:23 UTC (rev 1965)
@@ -357,7 +357,7 @@
     MokoGsmdConnectionPrivate* priv = GSMD_CONNECTION_GET_PRIVATE(self);
     g_return_if_fail( priv->handle );
     g_return_if_fail( number );
-    g_return_if_fail( strlen( number ) < 2 );
+    g_return_if_fail( strlen( number ) > 2 );
     struct lgsm_addr addr;
     addr.type = 129; //???
     g_stpcpy( &addr.addr[0], number );




--- End Message ---
--- Begin Message ---
Author: thomas
Date: 2007-05-16 15:11:12 +0200 (Wed, 16 May 2007)
New Revision: 1966

Modified:
   
trunk/src/target/OM-2007/applications/openmoko-dialer/src/dialer-callbacks-connection.c
   
trunk/src/target/OM-2007/applications/openmoko-dialer/src/dialer-callbacks-connection.h
   trunk/src/target/OM-2007/applications/openmoko-dialer/src/dialer-main.c
   
trunk/src/target/OM-2007/applications/openmoko-dialer/src/dialer-window-incoming.c
   
trunk/src/target/OM-2007/applications/openmoko-dialer/src/dialer-window-incoming.h
Log:
* openmoko-dialer/src/dialer-window-incoming.c:
* openmoko-dialer/src/dialer-callbacks-connection.c:
* openmoko-dialer/src/dialer-window-incoming.h:
* openmoko-dialer/src/dialer-callbacks-connection.h:
Implement incoming window responses and make use clip if available.

* openmoko-dialer/src/dialer-main.c: Move gtk initialisation to after single
* instance check. Add gsm power on and register functions.


Modified: 
trunk/src/target/OM-2007/applications/openmoko-dialer/src/dialer-callbacks-connection.c
===================================================================
--- 
trunk/src/target/OM-2007/applications/openmoko-dialer/src/dialer-callbacks-connection.c
     2007-05-16 10:45:23 UTC (rev 1965)
+++ 
trunk/src/target/OM-2007/applications/openmoko-dialer/src/dialer-callbacks-connection.c
     2007-05-16 13:11:12 UTC (rev 1966)
@@ -17,7 +17,8 @@
 }
 
 void
-incoming_clip_cb (MokoGsmdConnection *self, const char *number)
+incoming_clip_cb (MokoGsmdConnection *self, const char *number, MokoDialerData 
*data)
 {
   /* caller id */
+  window_incoming_update_message (data, number);
 }

Modified: 
trunk/src/target/OM-2007/applications/openmoko-dialer/src/dialer-callbacks-connection.h
===================================================================
--- 
trunk/src/target/OM-2007/applications/openmoko-dialer/src/dialer-callbacks-connection.h
     2007-05-16 10:45:23 UTC (rev 1965)
+++ 
trunk/src/target/OM-2007/applications/openmoko-dialer/src/dialer-callbacks-connection.h
     2007-05-16 13:11:12 UTC (rev 1966)
@@ -7,6 +7,6 @@
 
 void network_registration_cb (MokoGsmdConnection *self, int type, int lac, int 
cell);
 void incoming_call_cb (MokoGsmdConnection *self, int type, MokoDialerData 
*data);
-void incoming_clip_cb (MokoGsmdConnection *self, const char *number);
+void incoming_clip_cb (MokoGsmdConnection *self, const char *number, 
MokoDialerData *data);
 
 #endif

Modified: 
trunk/src/target/OM-2007/applications/openmoko-dialer/src/dialer-main.c
===================================================================
--- trunk/src/target/OM-2007/applications/openmoko-dialer/src/dialer-main.c     
2007-05-16 10:45:23 UTC (rev 1965)
+++ trunk/src/target/OM-2007/applications/openmoko-dialer/src/dialer-main.c     
2007-05-16 13:11:12 UTC (rev 1966)
@@ -144,9 +144,6 @@
 {
   pid_t lockapp;
 
-  /* Initialize GTK+ */
-  gtk_init (&argc, &argv);
-  moko_stock_register ();
 
   if (argc != 1)
   {
@@ -160,6 +157,7 @@
 
     g_option_context_free (context);
   }
+
   //FIXME: the following lines to enable unique instance will be changed.
   lockapp = testlock ("/tmp/dialer.lock");
   if (lockapp > 0)
@@ -169,6 +167,9 @@
   }
   setlock ("/tmp/dialer.lock");
 
+  /* Initialize GTK+ */
+  gtk_init (&argc, &argv);
+  moko_stock_register ();
 
   p_dialer_data = g_new0 (MokoDialerData, 1);
 
@@ -181,6 +182,9 @@
 
   /* Set up gsmd connection object */
   MokoGsmdConnection* conn = p_dialer_data->connection = 
moko_gsmd_connection_new ();
+  moko_gsmd_connection_set_antenna_power (conn, TRUE);
+  sleep (4); /* FIXME: this is horrible */
+  moko_gsmd_connection_network_register (conn);
   g_signal_connect (G_OBJECT (conn), "network-registration", (GCallback) 
network_registration_cb, p_dialer_data);
   g_signal_connect (G_OBJECT (conn), "incoming-call", (GCallback) 
incoming_call_cb, p_dialer_data);
   g_signal_connect (G_OBJECT (conn), "incoming-clip", (GCallback) 
incoming_clip_cb, p_dialer_data);

Modified: 
trunk/src/target/OM-2007/applications/openmoko-dialer/src/dialer-window-incoming.c
===================================================================
--- 
trunk/src/target/OM-2007/applications/openmoko-dialer/src/dialer-window-incoming.c
  2007-05-16 10:45:23 UTC (rev 1965)
+++ 
trunk/src/target/OM-2007/applications/openmoko-dialer/src/dialer-window-incoming.c
  2007-05-16 13:11:12 UTC (rev 1966)
@@ -209,14 +209,30 @@
   window = moko_message_dialog_new ();
 
   gtk_dialog_add_button (GTK_DIALOG (window), MOKO_STOCK_CALL_ANSWER, 
GTK_RESPONSE_OK);
-  gtk_dialog_add_button (GTK_DIALOG (window), MOKO_STOCK_CALL_REJECT, 
GTK_RESPONSE_OK);
-  moko_message_dialog_set_message (MOKO_MESSAGE_DIALOG (window), "Incoming 
Call");
+  gtk_dialog_add_button (GTK_DIALOG (window), MOKO_STOCK_CALL_REJECT, 
GTK_RESPONSE_CANCEL);
+  moko_message_dialog_set_message (MOKO_MESSAGE_DIALOG (window), "Incoming 
call");
 
 }
 
 void
 window_incoming_show (MokoDialerData *data)
 {
-  gtk_dialog_run (data->window_incoming);
+  if (gtk_dialog_run (GTK_DIALOG (data->window_incoming)) == GTK_RESPONSE_OK)
+  {
+    moko_gsmd_connection_voice_accept (data->connection);
+    /* dialer_window_talking_show (data); */
+    gtk_widget_show_all (data->window_talking);
+  }
+  else
+  {
+    moko_gsmd_connection_voice_hangup (data->connection);
+  }
+
   gtk_widget_hide (data->window_incoming);
 }
+
+void
+window_incoming_update_message (MokoDialerData *data, const gchar *clip)
+{
+  moko_message_dialog_set_message (MOKO_MESSAGE_DIALOG 
(data->window_incoming), "Incoming call from %s", clip);
+}

Modified: 
trunk/src/target/OM-2007/applications/openmoko-dialer/src/dialer-window-incoming.h
===================================================================
--- 
trunk/src/target/OM-2007/applications/openmoko-dialer/src/dialer-window-incoming.h
  2007-05-16 10:45:23 UTC (rev 1965)
+++ 
trunk/src/target/OM-2007/applications/openmoko-dialer/src/dialer-window-incoming.h
  2007-05-16 13:11:12 UTC (rev 1966)
@@ -24,5 +24,7 @@
 void window_incoming_init (MokoDialerData * p_dialer_data);
 void window_incoming_prepare (MokoDialerData * appdata);
 void window_incoming_show (MokoDialerData *data);
+void window_incoming_update_message (MokoDialerData *data, const gchar *clip);
 
+
 #endif




--- End Message ---
--- Begin Message ---
Author: thomas
Date: 2007-05-16 15:29:41 +0200 (Wed, 16 May 2007)
New Revision: 1967

Modified:
   trunk/src/target/OM-2007/artwork/themes/openmoko-standard/gtk-2.0/mokoicons
Log:
* remove missing images from theme


Modified: 
trunk/src/target/OM-2007/artwork/themes/openmoko-standard/gtk-2.0/mokoicons
===================================================================
--- trunk/src/target/OM-2007/artwork/themes/openmoko-standard/gtk-2.0/mokoicons 
2007-05-16 13:11:12 UTC (rev 1966)
+++ trunk/src/target/OM-2007/artwork/themes/openmoko-standard/gtk-2.0/mokoicons 
2007-05-16 13:29:41 UTC (rev 1967)
@@ -7,35 +7,6 @@
 stock["openmoko-filter-menu-icon"]        = {{"openmoko-filter-menu-icon.png"}}
 
 #
-# action button icons
-#
-# FIXME: add icons here or to openmoko-applications
-stock["openmoko-action-button-address-icon"]             = 
{{"openmoko-action-button-address-icon.png"}}
-stock["openmoko-action-button-concant-delete-icon"]      = 
{{"openmoko-action-button-concant-delete-icon.png"}}
-stock["openmoko-action-button-concant-mode-icon"]        = 
{{"openmoko-action-button-concant-mode-icon.png"}}
-stock["openmoko-action-button-delete-folder-icon"]       = 
{{"openmoko-action-button-delete-folder-icon.png"}}
-stock["openmoko-action-button-delete-message-icon"]      = 
{{"openmoko-action-button-delete-message-icon.png"}}
-stock["openmoko-action-button-edit-icon"]                = 
{{"openmoko-action-button-edit-icon.png"}}
-stock["openmoko-action-button-email-icon"]               = 
{{"openmoko-action-button-email-icon.png"}}
-stock["openmoko-action-button-getmail-icon"]             = 
{{"openmoko-action-button-getmail-icon.png"}}
-stock["openmoko-action-button-group-icon"]               = 
{{"openmoko-action-button-group-icon.png"}}
-stock["openmoko-action-button-history-icon"]             = 
{{"openmoko-action-button-history-icon.png"}}
-stock["openmoko-action-button-hold-icon"]                = 
{{"openmoko-action-button-hold-icon.png"}}
-stock["openmoko-action-button-mode-forward-icon"]        = 
{{"openmoko-action-button-mode-forward-icon.png"}}
-stock["openmoko-action-button-mode-read-icon"]           = 
{{"openmoko-action-button-mode-read-icon.png"}}
-stock["openmoko-action-button-mode-reply-icon"]          = 
{{"openmoko-action-button-mode-reply-icon.png"}}
-stock["openmoko-action-button-new-concant-icon"]         = 
{{"openmoko-action-button-new-concant-icon.png"}}
-stock["openmoko-action-button-new-folder-icon"]          = 
{{"openmoko-action-button-new-folder-icon.png"}}
-stock["openmoko-action-button-new-mail-icon"]            = 
{{"openmoko-action-button-new-mail-icon.png"}}
-stock["openmoko-action-button-new-sms-icon"]             = 
{{"openmoko-action-button-new-sms-icon.png"}}
-stock["openmoko-action-button-phone-book-icon"]          = 
{{"openmoko-action-button-phone-book-icon.png"}}
-stock["openmoko-action-button-phone-icon"]               = 
{{"openmoko-action-button-phone-icon.png"}}
-stock["openmoko-action-button-redial-icon"]              = 
{{"openmoko-action-button-redial-icon.png"}}
-stock["openmoko-action-button-search-icon"]              = 
{{"openmoko-action-button-search-icon.png"}}
-stock["openmoko-action-button-speaker-icon"]             = 
{{"openmoko-action-button-speaker-icon.png"}}
-stock["openmoko-action-button-view-icon"]                = 
{{"openmoko-action-button-view-icon.png"}}
-
-#
 # icons used in the openmoko today application
 #
 stock["openmoko-today-bell"] = {{"openmoko-today-bell.png"}}




--- End Message ---
--- Begin Message ---
Author: thomas
Date: 2007-05-16 15:44:30 +0200 (Wed, 16 May 2007)
New Revision: 1968

Modified:
   
trunk/src/target/OM-2007/applications/openmoko-dialer/src/dialer-window-incoming.c
Log:
openmoko-dialer: make sure incoming window is initialised


Modified: 
trunk/src/target/OM-2007/applications/openmoko-dialer/src/dialer-window-incoming.c
===================================================================
--- 
trunk/src/target/OM-2007/applications/openmoko-dialer/src/dialer-window-incoming.c
  2007-05-16 13:29:41 UTC (rev 1967)
+++ 
trunk/src/target/OM-2007/applications/openmoko-dialer/src/dialer-window-incoming.c
  2007-05-16 13:44:30 UTC (rev 1968)
@@ -217,6 +217,11 @@
 void
 window_incoming_show (MokoDialerData *data)
 {
+  if (!data->window_incoming)
+  {
+    window_incoming_init (data);
+  }
+
   if (gtk_dialog_run (GTK_DIALOG (data->window_incoming)) == GTK_RESPONSE_OK)
   {
     moko_gsmd_connection_voice_accept (data->connection);




--- End Message ---
--- Begin Message ---
Author: thomas
Date: 2007-05-16 17:16:48 +0200 (Wed, 16 May 2007)
New Revision: 1969

Modified:
   
trunk/src/target/OM-2007/applications/openmoko-dialer/src/dialer-window-incoming.c
Log:
openmoko-dialer: fix window_incoming_init ()


Modified: 
trunk/src/target/OM-2007/applications/openmoko-dialer/src/dialer-window-incoming.c
===================================================================
--- 
trunk/src/target/OM-2007/applications/openmoko-dialer/src/dialer-window-incoming.c
  2007-05-16 13:44:30 UTC (rev 1968)
+++ 
trunk/src/target/OM-2007/applications/openmoko-dialer/src/dialer-window-incoming.c
  2007-05-16 15:16:48 UTC (rev 1969)
@@ -199,11 +199,11 @@
 }
 
 void
-window_incoming_init (MokoDialerData * p_dialer_data) 
+window_incoming_init (MokoDialerData * data) 
 {
   GtkWidget * window;
 
-  if (p_dialer_data->window_incoming)
+  if (data->window_incoming)
      return;
 
   window = moko_message_dialog_new ();
@@ -212,6 +212,8 @@
   gtk_dialog_add_button (GTK_DIALOG (window), MOKO_STOCK_CALL_REJECT, 
GTK_RESPONSE_CANCEL);
   moko_message_dialog_set_message (MOKO_MESSAGE_DIALOG (window), "Incoming 
call");
 
+  data->window_incoming = window;
+
 }
 
 void




--- End Message ---
--- Begin Message ---
Author: laforge
Date: 2007-05-16 17:46:56 +0200 (Wed, 16 May 2007)
New Revision: 1970

Added:
   trunk/src/target/kernel/patches/hxd8-tsl256x.patch
Modified:
   trunk/src/target/kernel/patches/series
Log:
* Add new TSL256x ambient light sensor driver


Added: trunk/src/target/kernel/patches/hxd8-tsl256x.patch
===================================================================
--- trunk/src/target/kernel/patches/hxd8-tsl256x.patch  2007-05-16 15:16:48 UTC 
(rev 1969)
+++ trunk/src/target/kernel/patches/hxd8-tsl256x.patch  2007-05-16 15:46:56 UTC 
(rev 1970)
@@ -0,0 +1,517 @@
+Index: linux-2.6.21-moko/drivers/i2c/chips/tsl256x.c
+===================================================================
+--- /dev/null
++++ linux-2.6.21-moko/drivers/i2c/chips/tsl256x.c
+@@ -0,0 +1,310 @@
++/*
++ * tsl256x.c  --  TSL256x Light Sensor driver
++ *
++ * Copyright 2007 by Fiwin.
++ * Author: Alec Tsai <[EMAIL PROTECTED]>
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License version 2 as
++ * published by the Free Software Foundation.
++ *
++ * This I2C client driver refers to pcf50606.c.
++ */
++
++#include <linux/module.h>
++#include <linux/init.h>
++#include <linux/i2c.h>
++#include <linux/types.h>
++#include <linux/input.h>
++
++#include "tsl256x.h"
++
++static unsigned short normal_i2c[] = { 0x39, I2C_CLIENT_END };
++/* Magic definition of all other variables and things */
++I2C_CLIENT_INSMOD;
++
++struct tsl256x_data {
++      struct i2c_client       client;
++      struct mutex            lock;
++      struct input_dev        *input_dev;
++};
++
++static struct i2c_driver tsl256x_driver;
++
++/******************************************************************************
++ * Low-Level routines
++ 
*****************************************************************************/
++static inline int __reg_write(struct tsl256x_data *tsl, u_int8_t reg,
++                                                              u_int8_t val)
++{
++      return i2c_smbus_write_byte_data(&tsl->client, reg, val);
++}
++
++static int reg_write(struct tsl256x_data *tsl, u_int8_t reg, u_int8_t val)
++{
++      int ret;
++
++      mutex_lock(&tsl->lock);
++      ret = __reg_write(tsl, reg, val);
++      mutex_unlock(&tsl->lock);
++
++      return ret;
++}
++
++static inline int32_t __reg_read(struct tsl256x_data *tsl, u_int8_t reg)
++{
++      int32_t ret;
++
++      ret = i2c_smbus_read_byte_data(&tsl->client, reg);
++
++      return ret;
++}
++
++static u_int8_t reg_read(struct tsl256x_data *tsl, u_int8_t reg)
++{
++      int32_t ret;
++
++      mutex_lock(&tsl->lock);
++      ret = __reg_read(tsl, reg);
++      mutex_unlock(&tsl->lock);
++
++      return ret & 0xff;
++}
++
++u_int32_t calculate_lux(u_int32_t iGain, u_int32_t iType, u_int32_t ch0,
++                                              u_int32_t ch1)
++{
++      u_int32_t channel0 = ch0 * 636 / 10;
++      u_int32_t channel1 = ch1 * 636 / 10;
++      u_int32_t lux_value = 0;
++      u_int32_t ratio = (channel1 * (2^RATIO_SCALE)) / channel0;
++      u_int32_t b = 0, m = 0;
++
++      if (0 == ch0)
++              return 0;
++      else {
++              if (ratio > (13 * (2^RATIO_SCALE) / 10))
++                      return 0;
++      }
++
++      switch (iType) {
++              case 0: // T package
++                      if ((ratio >= 0) && (ratio <= K1T)) {
++                              b = B1T;
++                              m = M1T;
++                      } else if (ratio <= K2T) {
++                              b = B2T;
++                              m = M2T;
++                      } else if (ratio <= K3T) {
++                              b = B3T;
++                              m = M3T;
++                      } else if (ratio <= K4T) {
++                              b = B4T;
++                              m = M4T;
++                      } else if (ratio <= K5T) {
++                              b = B5T;
++                              m = M5T;
++                      } else if (ratio <= K6T) {
++                              b = B6T;
++                              m = M6T;
++                      } else if (ratio <= K7T) {
++                              b = B7T;
++                              m = M7T;
++                      } else if (ratio > K8T) {
++                              b = B8T;
++                              m = M8T;
++                      }
++              break;
++              case 1:// CS package
++                      if ((ratio >= 0) && (ratio <= K1C)) {
++                              b = B1C;
++                              m = M1C;
++                      } else if (ratio <= K2C) {
++                              b = B2C;
++                              m = M2C;
++                      } else if (ratio <= K3C) {
++                              b = B3C;
++                              m = M3C;
++                      } else if (ratio <= K4C) {
++                              b = B4C;
++                              m = M4C;
++                      } else if (ratio <= K5C) {
++                              b = B5C;
++                              m = M5C;
++                      } else if (ratio <= K6C) {
++                              b = B6C;
++                              m = M6C;
++                      } else if (ratio <= K7C) {
++                              b = B7C;
++                              m = M7C;
++                      } else if (ratio > K8C) {
++                              b = B8C;
++                              m = M8C;
++                      }
++              break;
++              default:
++                      return 0;
++              break;
++      }
++
++      lux_value = ((channel0 * b) - (channel1 * m)) / 16384;
++      return(lux_value);
++}
++
++static ssize_t tsl256x_show_light_lux(struct device *dev,
++                                      struct device_attribute *attr, char 
*buf)
++{
++      struct i2c_client *client = to_i2c_client(dev);
++      struct tsl256x_data *tsl = i2c_get_clientdata(client);
++      u_int8_t low_byte_of_ch0 = 0, high_byte_of_ch0 = 0;
++      u_int8_t low_byte_of_ch1 = 0, high_byte_of_ch1 = 0;
++      u_int32_t adc_value_ch0, adc_value_ch1, adc_value;
++
++      low_byte_of_ch0 = reg_read(tsl, TSL256X_REG_DATA0LOW);
++      high_byte_of_ch0 = reg_read(tsl, TSL256X_REG_DATA0HIGH);
++      low_byte_of_ch1 = reg_read(tsl, TSL256X_REG_DATA1LOW);
++      high_byte_of_ch1 = reg_read(tsl, TSL256X_REG_DATA1HIGH);
++
++      adc_value_ch0 = (high_byte_of_ch0 * 256 + low_byte_of_ch0) * 16;
++      adc_value_ch1 = (high_byte_of_ch1 * 256 + low_byte_of_ch1) * 16;
++
++      adc_value = calculate_lux(0, 0, adc_value_ch0, adc_value_ch1);
++      return sprintf(buf, "%d\n", adc_value);
++}
++
++static DEVICE_ATTR(light_lux, S_IRUGO, tsl256x_show_light_lux, NULL);
++
++static int tsl256x_detect(struct i2c_adapter *adapter, int address, int kind)
++{
++      struct i2c_client *new_client = NULL;
++      struct tsl256x_data *tsl256x = NULL;
++      u_int8_t id = 0;
++      int res = 0;
++
++      if (!(tsl256x = kzalloc(sizeof(*tsl256x), GFP_KERNEL)))
++              return -ENOMEM;
++
++      mutex_init(&tsl256x->lock);
++      new_client = &tsl256x->client;
++      i2c_set_clientdata(new_client, tsl256x);
++      new_client->addr = address;
++      new_client->adapter = adapter;
++      new_client->driver = &tsl256x_driver;
++      new_client->flags = 0;
++      strlcpy(new_client->name, "tsl256x", I2C_NAME_SIZE);
++
++      /* now we try to detect the chip */
++      /* register with i2c core */
++      res = i2c_attach_client(new_client);
++      if (res) {
++              printk(KERN_DEBUG "[%s]Error: during i2c_attach_client()\n",
++                      new_client->name);
++              goto exit_free;
++      } else {
++              printk(KERN_INFO "TSL256X is attached to I2C bus.\n");
++      }
++
++      /* Configure TSL256X. */
++      {
++              /* Power up TSL256X. */
++              reg_write(tsl256x, TSL256X_REG_CONTROL, 0x03);
++
++              /* Check TSL256X ID. */
++              id = reg_read(tsl256x, TSL256X_REG_ID);
++              if (TSL2561_ID == (id & 0xF0)) {
++                      /* Configuring the Timing Register.
++                              High Gain (16x), integration time of 101ms. */
++                      reg_write(tsl256x, TSL256X_REG_TIMING, 0x11);
++              } else {
++                      goto exit_free;
++              }
++      }
++
++      res = device_create_file(&new_client->dev, &dev_attr_light_lux);
++      if (res)
++              goto exit_detach;
++
++      return 0;
++
++exit_free:
++      kfree(tsl256x);
++      return res;
++exit_detach:
++      i2c_detach_client(new_client);
++      return res;
++}
++
++static int tsl256x_attach_adapter(struct i2c_adapter *adapter)
++{
++      return i2c_probe(adapter, &addr_data, &tsl256x_detect);
++}
++
++static int tsl256x_detach_client(struct i2c_client *client)
++{
++      struct tsl256x_data *tsl256x = i2c_get_clientdata(client);
++
++      printk(KERN_INFO "Detach TSL256X from I2C bus.\n");
++
++      /* Power down TSL256X. */
++      reg_write(tsl256x, TSL256X_REG_CONTROL, 0x00);
++
++      device_remove_file(&client->dev, &dev_attr_light_lux);
++      kfree(tsl256x);
++
++      return 0;
++}
++
++#ifdef CONFIG_PM
++static int tsl256x_suspend(struct device *dev, pm_message_t state)
++{
++      struct i2c_client *client = to_i2c_client(dev);
++      struct tsl256x_data *tsl256x = i2c_get_clientdata(client);
++
++      /* Power down TSL256X. */
++      reg_write(tsl256x, TSL256X_REG_CONTROL, 0x00);
++
++      return 0;
++}
++
++static int tsl256x_resume(struct device *dev)
++{
++      struct i2c_client *client = to_i2c_client(dev);
++      struct tsl256x_data *tsl256x = i2c_get_clientdata(client);
++
++      /* Power up TSL256X. */
++      reg_write(tsl256x, TSL256X_REG_CONTROL, 0x03);
++
++      return 0;
++}
++#endif
++
++static struct i2c_driver tsl256x_driver = {
++      .driver = {
++              .name           = "tsl256x",
++              .owner          = THIS_MODULE,
++#ifdef CONFIG_PM
++              .suspend        = &tsl256x_suspend,
++              .resume         = &tsl256x_resume,
++#endif
++      },
++      .id                             = I2C_DRIVERID_TSL256X,
++      .attach_adapter = &tsl256x_attach_adapter,
++      .detach_client  = &tsl256x_detach_client,
++};
++
++static int __init tsl256x_init(void)
++{
++      return i2c_add_driver(&tsl256x_driver);
++}
++
++static void __exit tsl256x_exit(void)
++{
++      i2c_del_driver(&tsl256x_driver);
++}
++
++MODULE_AUTHOR("Alec Tsai <[EMAIL PROTECTED]>");
++MODULE_LICENSE("GPL");
++
++module_init(tsl256x_init);
++module_exit(tsl256x_exit);
++
+Index: linux-2.6.21-moko/drivers/i2c/chips/tsl256x.h
+===================================================================
+--- /dev/null
++++ linux-2.6.21-moko/drivers/i2c/chips/tsl256x.h
+@@ -0,0 +1,154 @@
++/*
++ * tsl256x.h  --  TSL256x Light Sensor driver
++ *
++ * Copyright 2007 by Fiwin.
++ * Author: Alec Tsai <[EMAIL PROTECTED]>
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License version 2 as
++ * published by the Free Software Foundation.
++ *
++ * The contents of header file is copied from TSL256x Datasheet.
++ */
++
++#ifndef _TSL256X_H
++#define _TSL256X_H
++
++#define       TSL2560_ID              0x00
++#define       TSL2561_ID              0x10
++
++#define LUX_SCALE             14              /* scale by 2^14 */
++#define RATIO_SCALE           9               /*scale ratio by 2^9 */
++
++/******************************************************************************
++ * Integration time scaling factors
++ 
*****************************************************************************/
++#define CH_SCALE              10              /* scale channel values by 2^10 
*/
++#define CHSCALE_TINT0 0x7517  /* 322/11 * 2^CH_SCALE */
++#define CHSCALE_TINT1 0x0fe7  /* 322/81 * 2^CH_SCALE */
++
++/******************************************************************************
++ * T Package coefficients
++ 
*****************************************************************************/
++/*
++ * For Ch1/Ch0=0.00 to 0.50
++ * Lux/Ch0=0.0304.0.062*((Ch1/Ch0)^1.4)
++ * piecewise approximation
++ * For Ch1/Ch0=0.00 to 0.125:
++ * Lux/Ch0=0.0304.0.0272*(Ch1/Ch0)
++ *
++ * For Ch1/Ch0=0.125 to 0.250:
++ * Lux/Ch0=0.0325.0.0440*(Ch1/Ch0)
++ *
++ * For Ch1/Ch0=0.250 to 0.375:
++ * Lux/Ch0=0.0351.0.0544*(Ch1/Ch0)
++ *
++ * For Ch1/Ch0=0.375 to 0.50:
++ * Lux/Ch0=0.0381.0.0624*(Ch1/Ch0)
++ *
++ * For Ch1/Ch0=0.50 to 0.61:
++ * Lux/Ch0=0.0224.0.031*(Ch1/Ch0)
++ *
++ * For Ch1/Ch0=0.61 to 0.80:
++ * Lux/Ch0=0.0128.0.0153*(Ch1/Ch0)
++ *
++ * For Ch1/Ch0=0.80 to 1.30:
++ * Lux/Ch0=0.00146.0.00112*(Ch1/Ch0)
++ *
++ * For Ch1/Ch0>1.3:
++ * Lux/Ch0=0
++ */
++#define K1T 0x0040 /* 0.125 * 2^RATIO_SCALE */
++#define B1T 0x01f2 /* 0.0304 * 2^LUX_SCALE */
++#define M1T 0x01be /* 0.0272 * 2^LUX_SCALE */
++#define K2T 0x0080 /* 0.250 * 2^RATIO_SCALE */
++#define B2T 0x0214 /* 0.0325 * 2^LUX_SCALE */
++#define M2T 0x02d1 /* 0.0440 * 2^LUX_SCALE */
++#define K3T 0x00c0 /* 0.375 * 2^RATIO_SCALE */
++#define B3T 0x023f /* 0.0351 * 2^LUX_SCALE */
++#define M3T 0x037b /* 0.0544 * 2^LUX_SCALE */
++#define K4T 0x0100 /* 0.50 * 2^RATIO_SCALE */
++#define B4T 0x0270 /* 0.0381 * 2^LUX_SCALE */
++#define M4T 0x03fe /* 0.0624 * 2^LUX_SCALE */
++#define K5T 0x0138 /* 0.61 * 2^RATIO_SCALE */
++#define B5T 0x016f /* 0.0224 * 2^LUX_SCALE */
++#define M5T 0x01fc /* 0.0310 * 2^LUX_SCALE */
++#define K6T 0x019a /* 0.80 * 2^RATIO_SCALE */
++#define B6T 0x00d2 /* 0.0128 * 2^LUX_SCALE */
++#define M6T 0x00fb /* 0.0153 * 2^LUX_SCALE */
++#define K7T 0x029a /* 1.3 * 2^RATIO_SCALE */
++#define B7T 0x0018 /* 0.00146 * 2^LUX_SCALE */
++#define M7T 0x0012 /* 0.00112 * 2^LUX_SCALE */
++#define K8T 0x029a /* 1.3 * 2^RATIO_SCALE */
++#define B8T 0x0000 /* 0.000 * 2^LUX_SCALE */
++#define M8T 0x0000 /* 0.000 * 2^LUX_SCALE */
++
++/******************************************************************************
++ * CS package coefficients
++ 
*****************************************************************************/
++/*
++ * For 0 <= Ch1/Ch0 <= 0.52
++ * Lux/Ch0 = 0.0315.0.0593*((Ch1/Ch0)^1.4)
++ * piecewise approximation
++ * For 0 <= Ch1/Ch0 <= 0.13
++ * Lux/Ch0 = 0.0315.0.0262*(Ch1/Ch0)
++ * For 0.13 <= Ch1/Ch0 <= 0.26
++ * Lux/Ch0 = 0.0337.0.0430*(Ch1/Ch0)
++ * For 0.26 <= Ch1/Ch0 <= 0.39
++ * Lux/Ch0 = 0.0363.0.0529*(Ch1/Ch0)
++ * For 0.39 <= Ch1/Ch0 <= 0.52
++ * Lux/Ch0 = 0.0392.0.0605*(Ch1/Ch0)
++ * For 0.52 < Ch1/Ch0 <= 0.65
++ * Lux/Ch0 = 0.0229.0.0291*(Ch1/Ch0)
++ * For 0.65 < Ch1/Ch0 <= 0.80
++ * Lux/Ch0 = 0.00157.0.00180*(Ch1/Ch0)
++ * For 0.80 < Ch1/Ch0 <= 1.30
++ * Lux/Ch0 = 0.00338.0.00260*(Ch1/Ch0)
++ * For Ch1/Ch0 > 1.30
++ * Lux = 0
++ */
++#define K1C 0x0043 /* 0.130 * 2^RATIO_SCALE */
++#define B1C 0x0204 /* 0.0315 * 2^LUX_SCALE */
++#define M1C 0x01ad /* 0.0262 * 2^LUX_SCALE */
++#define K2C 0x0085 /* 0.260 * 2^RATIO_SCALE */
++#define B2C 0x0228 /* 0.0337 * 2^LUX_SCALE */
++#define M2C 0x02c1 /* 0.0430 * 2^LUX_SCALE */
++#define K3C 0x00c8 /* 0.390 * 2^RATIO_SCALE */
++#define B3C 0x0253 /* 0.0363 * 2^LUX_SCALE */
++#define M3C 0x0363 /* 0.0529 * 2^LUX_SCALE */
++#define K4C 0x010a /* 0.520 * 2^RATIO_SCALE */
++#define B4C 0x0282 /* 0.0392 * 2^LUX_SCALE */
++#define M4C 0x03df /* 0.0605 * 2^LUX_SCALE */
++#define K5C 0x014d /* 0.65 * 2^RATIO_SCALE */
++#define B5C 0x0177 /* 0.0229 * 2^LUX_SCALE */
++#define M5C 0x01dd /* 0.0291 * 2^LUX_SCALE */
++#define K6C 0x019a /* 0.80 * 2^RATIO_SCALE */
++#define B6C 0x0101 /* 0.0157 * 2^LUX_SCALE */
++#define M6C 0x0127 /* 0.0180 * 2^LUX_SCALE */
++#define K7C 0x029a /* 1.3 * 2^RATIO_SCALE */
++#define B7C 0x0037 /* 0.00338 * 2^LUX_SCALE */
++#define M7C 0x002b /* 0.00260 * 2^LUX_SCALE */
++#define K8C 0x029a /* 1.3 * 2^RATIO_SCALE */
++#define B8C 0x0000 /* 0.000 * 2^LUX_SCALE */
++#define M8C 0x0000 /* 0.000 * 2^LUX_SCALE */
++
++/* TSL256x registers definition . */
++enum tsl256x_regs {
++      TSL256X_REG_CONTROL                     = 0x80, /* Control of basic 
functions */
++      TSL256X_REG_TIMING                      = 0x81, /* Integration 
time/gain control */
++      TSL256X_REG_THRESHLOWLOW        = 0x82, /* Low byte of low interrupt 
threshold */
++      TSL256X_REG_THRESHLOWHIGH       = 0x83, /* High byte of low interrupt 
threshold */
++      TSL256X_REG_THRESHHIGHLOW       = 0x84, /* Low byte of high interrupt 
threshold */
++      TSL256X_REG_THRESHHIGHHIGH      = 0x85, /* High byte of high interrupt 
threshold */
++      TSL256X_REG_INTERRUPT           = 0x86, /* Interrupt control */
++      TSL256X_REG_CRC                         = 0x88, /* Factory test - not a 
user register */
++      TSL256X_REG_ID                          = 0x8A, /* Part number/ Rev ID 
*/
++      TSL256X_REG_DATA0LOW            = 0x8C, /* Low byte of ADC channel 0 */
++      TSL256X_REG_DATA0HIGH           = 0x8D, /* High byte of ADC channel 0 */
++      TSL256X_REG_DATA1LOW            = 0x8E, /* Low byte of ADC channel 1 */
++      TSL256X_REG_DATA1HIGH           = 0x8F, /* High byte of ADC channel 1 */
++      __NUM_TSL256X_REGS
++};
++
++#endif /* _TSL256X_H */
++
+Index: linux-2.6.21-moko/drivers/i2c/chips/Kconfig
+===================================================================
+--- linux-2.6.21-moko.orig/drivers/i2c/chips/Kconfig
++++ linux-2.6.21-moko/drivers/i2c/chips/Kconfig
+@@ -136,4 +136,14 @@
+         This driver can also be built as a module.  If so, the module
+         will be called max6875.
+ 
++config SENSORS_TSL256X
++      tristate "Texas TSL256X Ambient Light Sensor"
++      depends on I2C
++      help
++        If you say yes here you get support for the Texas TSL256X
++        ambient light sensor chip.
++
++        This driver can also be built as a module.  If so, the module
++        will be called tsl256x.
++
+ endmenu
+Index: linux-2.6.21-moko/drivers/i2c/chips/Makefile
+===================================================================
+--- linux-2.6.21-moko.orig/drivers/i2c/chips/Makefile
++++ linux-2.6.21-moko/drivers/i2c/chips/Makefile
+@@ -13,6 +13,7 @@
+ obj-$(CONFIG_SENSORS_PCF8591) += pcf8591.o
+ obj-$(CONFIG_ISP1301_OMAP)    += isp1301_omap.o
+ obj-$(CONFIG_TPS65010)                += tps65010.o
++obj-$(CONFIG_SENSORS_TSL256X) += tsl256x.o
+ 
+ ifeq ($(CONFIG_I2C_DEBUG_CHIP),y)
+ EXTRA_CFLAGS += -DDEBUG
+Index: linux-2.6.21-moko/include/linux/i2c-id.h
+===================================================================
+--- linux-2.6.21-moko.orig/include/linux/i2c-id.h
++++ linux-2.6.21-moko/include/linux/i2c-id.h
+@@ -160,6 +160,7 @@
+ #define I2C_DRIVERID_W83L785TS 1047
+ #define I2C_DRIVERID_OV7670 1048      /* Omnivision 7670 camera */
+ #define I2C_DRIVERID_PCF50606 1049
++#define I2C_DRIVERID_TSL256X 1050
+ 
+ /*
+  * ---- Adapter types ----------------------------------------------------

Modified: trunk/src/target/kernel/patches/series
===================================================================
--- trunk/src/target/kernel/patches/series      2007-05-16 15:16:48 UTC (rev 
1969)
+++ trunk/src/target/kernel/patches/series      2007-05-16 15:46:56 UTC (rev 
1970)
@@ -35,3 +35,4 @@
 hxd8-core.patch
 s3c2410_fb-truecolor.patch
 s3c2440-nand-disable-hwecc.patch
+hxd8-tsl256x.patch




--- End Message ---
_______________________________________________
commitlog mailing list
[email protected]
http://lists.openmoko.org/mailman/listinfo/commitlog

Reply via email to