Introduced a special gate-type for constants.

--- CircTypes.h
+++ CircTypes.h
@@ -27,7 +27,7 @@
 //=================================================================================================
 // Helper types (analogues of Var/Lit types from MiniSat):

-typedef enum { gtype_Inp = 0, gtype_And = 1 } GateType;
+typedef enum { gtype_Inp = 0, gtype_And = 1, gtype_Const = 2 } GateType;

 //-------------------------------------------------------------------------------------------------
 // Gate-type: (analogue of MiniSat's Var)
@@ -41,12 +41,12 @@
     bool operator <  (Gate p) const { return x < p.x;  }
 };

+const Gate gate_Undef = { ((1U << 30)-1) << 2 };
+const Gate gate_True  = { 0 };
+
 // Use this as a constructor:
 inline Gate         mkGate  (unsigned int id, GateType t){ Gate g; g.x = (id << 2) + t; return g; }
-inline GateType     type    (Gate g) { return GateType(g.x & 1); }
-
-const Gate gate_Undef = { ((1U << 30)-1) << 2 };
-const Gate gate_True  = { 0 };
+inline GateType     type    (Gate g){ return g == gate_True ? gtype_Const : GateType(g.x & 1); }

 // Note! Use GMap instead of this:
 inline unsigned int index (Gate g) { return g.x >> 2; }
@@ -62,6 +62,13 @@
     bool operator <  (Sig p) const { return x < p.x;  } // '<' makes p, ~p adjacent in the ordering.
 };

+//const Sig lit_Undef = mkSig(var_Undef, false);  // }- Useful special constants.
+//const Sig lit_Error = mkSig(var_Undef, true );  // }
+
+const Sig sig_Undef = { ((1U << 30)-1) << 2 };  // }- Useful special constants.
+const Sig sig_Error = { (((1U << 30)-1) << 2) + 2};  // }
+const Sig sig_True  = { 0 };
+const Sig sig_False = { 2 };

 // Use this as a constructor:
 inline  Sig mkSig(Gate g, bool sign = false){
@@ -71,18 +78,10 @@
 inline  Sig      operator ^(Sig p, bool b)               { Sig q; q.x = p.x ^ (((unsigned int)b)<<1); return q; }
 inline  bool     sign      (Sig p)                       { return bool(p.x & 2); }
 inline  Gate     gate      (Sig p)                       { return mkGate(p.x >> 2, GateType(p.x & 1)); }
-inline  GateType type      (Sig p)                       { return GateType(p.x & 1); }
+inline  GateType type      (Sig p)                       { return type(gate(p)); }

 // Mapping Sigerals to and from compact integers suitable for array indexing:
 inline  Sig          toSig     (unsigned  i)         { Sig p; p.x = i; return p; }
-
-//const Sig lit_Undef = mkSig(var_Undef, false);  // }- Useful special constants.
-//const Sig lit_Error = mkSig(var_Undef, true );  // }
-
-const Sig sig_Undef = { ((1U << 30)-1) << 2 };  // }- Useful special constants.
-const Sig sig_Error = { (((1U << 30)-1) << 2) + 2};  // }
-const Sig sig_True  = { 0 };
-const Sig sig_False = { 2 };

 // Note! Use SMap instead of this:
 inline unsigned int index (Sig s) { return s.x >> 1; }


- next step to text clipboards - text passed now without a null-terminator,   and it's a system duty to add ( or not to add) one.

--- Clipboard.c
+++ Clipboard.c
@@ -359,7 +359,6 @@
    case cefFetch:
       s = (char*)apc_clipboard_get_data( self, cfText, (int*)&len);
       if (s) {
-         if ( len > 0 && s[len-1] == '\0') len--;
          data = newSVpv( s, len);
          free(s);
          return data;
@@ -368,7 +367,7 @@

    case cefStore:
       s = SvPV( data, len);
-      apc_clipboard_set_data( self, cfText, (void*)s, len+1);
+      apc_clipboard_set_data( self, cfText, (void*)s, len);
       break;
    }
    return nilSV;


add a missing HTTP error code

add a missing HTTP error code

--- src/include/baselib/http/Globals.h
+++ src/include/baselib/http/Globals.h
@@ -153,6 +153,7 @@
                 HTTP_SERVER_ERROR_NOT_IMPLEMENTED       = 501U,
                 HTTP_SERVER_ERROR_BAD_GATEWAY           = 502U,
                 HTTP_SERVER_ERROR_SERVICE_UNAVAILABLE   = 503U,
+                HTTP_SERVER_ERROR_GATEWAY_TIMEOUT       = 504U,
             };

             enum : long


* avoid dup symbols for arm
Review URL: http://codereview.chromium.org/177038

git-svn-id: 721b910a23eff8a86f00c8fd261a7587cddf18f8@638 fcba33aa-ac0c-11dd-b9e7-8d5594d729c2

--- src/include/linux/arm/atomic_ops.h
+++ src/include/linux/arm/atomic_ops.h
@@ -38,7 +38,7 @@
 typedef intptr_t AtomicWord;
 typedef int32_t Atomic32;

-inline AtomicWord CompareAndSwap(volatile AtomicWord* ptr,
+static inline AtomicWord CompareAndSwap(volatile AtomicWord* ptr,
                                  AtomicWord old_value,
                                  AtomicWord new_value) {
   uint32_t old, tmp;
@@ -57,7 +57,7 @@
   return old;
 }

-inline AtomicWord AtomicExchange(volatile AtomicWord* ptr,
+static inline AtomicWord AtomicExchange(volatile AtomicWord* ptr,
                                  AtomicWord new_value) {
   uint32_t tmp, old;

@@ -73,7 +73,7 @@
   return old;
 }

-inline AtomicWord AtomicIncrement(volatile AtomicWord* ptr,
+static inline AtomicWord AtomicIncrement(volatile AtomicWord* ptr,
                                   AtomicWord increment) {
   uint32_t tmp, res;


anv/cmd_buffer: Fix bad indentation

anv/cmd_buffer: Fix bad indentation

A bunch of code was indented in such a way that it looked like it went
with the if statement above but it definitely didn't.

Reviewed-by: Iago Toral Quiroga <a847aabaac44184372f6b1cd1a59aa254daaeb0b@igalia.com>
Cc: "17.0 13.0" <59f39c0db42d4479a46b02d4d2bc11120e37bb44@lists.freedesktop.org>

--- src/intel/vulkan/genX_cmd_buffer.c
+++ src/intel/vulkan/genX_cmd_buffer.c
@@ -2133,32 +2133,33 @@
     */
    if (pipeline == GPGPU)
       anv_batch_emit(&cmd_buffer->batch, GENX(3DSTATE_CC_STATE_POINTERS), t);
+
 #elif GEN_GEN <= 7
-      /* From "BXML » GT » MI » vol1a GPU Overview » [Instruction]
-       * PIPELINE_SELECT [DevBWR+]":
-       *
-       *   Project: DEVSNB+
-       *
-       *   Software must ensure all the write caches are flushed through a
-       *   stalling PIPE_CONTROL command followed by another PIPE_CONTROL
-       *   command to invalidate read only caches prior to programming
-       *   MI_PIPELINE_SELECT command to change the Pipeline Select Mode.
-       */
-      anv_batch_emit(&cmd_buffer->batch, GENX(PIPE_CONTROL), pc) {
-         pc.RenderTargetCacheFlushEnable  = true;
-         pc.DepthCacheFlushEnable         = true;
-         pc.DCFlushEnable                 = true;
-         pc.PostSyncOperation             = NoWrite;
-         pc.CommandStreamerStallEnable    = true;
-      }
-
-      anv_batch_emit(&cmd_buffer->batch, GENX(PIPE_CONTROL), pc) {
-         pc.TextureCacheInvalidationEnable   = true;
-         pc.ConstantCacheInvalidationEnable  = true;
-         pc.StateCacheInvalidationEnable     = true;
-         pc.InstructionCacheInvalidateEnable = true;
-         pc.PostSyncOperation                = NoWrite;
-      }
+   /* From "BXML » GT » MI » vol1a GPU Overview » [Instruction]
+    * PIPELINE_SELECT [DevBWR+]":
+    *
+    *   Project: DEVSNB+
+    *
+    *   Software must ensure all the write caches are flushed through a
+    *   stalling PIPE_CONTROL command followed by another PIPE_CONTROL
+    *   command to invalidate read only caches prior to programming
+    *   MI_PIPELINE_SELECT command to change the Pipeline Select Mode.
+    */
+   anv_batch_emit(&cmd_buffer->batch, GENX(PIPE_CONTROL), pc) {
+      pc.RenderTargetCacheFlushEnable  = true;
+      pc.DepthCacheFlushEnable         = true;
+      pc.DCFlushEnable                 = true;
+      pc.PostSyncOperation             = NoWrite;
+      pc.CommandStreamerStallEnable    = true;
+   }
+
+   anv_batch_emit(&cmd_buffer->batch, GENX(PIPE_CONTROL), pc) {
+      pc.TextureCacheInvalidationEnable   = true;
+      pc.ConstantCacheInvalidationEnable  = true;
+      pc.StateCacheInvalidationEnable     = true;
+      pc.InstructionCacheInvalidateEnable = true;
+      pc.PostSyncOperation                = NoWrite;
+   }
 #endif
 }


anv/cmd_buffer: Move the clear_subpasses calls to set_subpass

Signed-off-by: Jason Ekstrand <68c46a606457643eab92053c1c05574abb26f861@jlekstrand.net>
Reviewed-by: Nanley Chery <d78cd5d33e98a5581566f188959f731bd0b1c0fd@intel.com>

--- src/intel/vulkan/genX_cmd_buffer.c
+++ src/intel/vulkan/genX_cmd_buffer.c
@@ -1305,6 +1305,8 @@
    cmd_buffer->state.dirty |= ANV_CMD_DIRTY_RENDER_TARGETS;

    cmd_buffer_emit_depth_stencil(cmd_buffer);
+
+   anv_cmd_buffer_clear_subpass(cmd_buffer);
 }

 void genX(CmdBeginRenderPass)(
@@ -1324,7 +1326,6 @@
    genX(flush_pipeline_select_3d)(cmd_buffer);

    genX(cmd_buffer_set_subpass)(cmd_buffer, pass->subpasses);
-   anv_cmd_buffer_clear_subpass(cmd_buffer);
 }

 void genX(CmdNextSubpass)(
@@ -1337,7 +1338,6 @@

    anv_cmd_buffer_resolve_subpass(cmd_buffer);
    genX(cmd_buffer_set_subpass)(cmd_buffer, cmd_buffer->state.subpass + 1);
-   anv_cmd_buffer_clear_subpass(cmd_buffer);
 }

 void genX(CmdEndRenderPass)(


linux_serial_stm32_target_reset(): add comment explaining BOOT0/RST waveforms


Create CountWord.c

Create CountWord.c

This is not final. I plan to add functionalities later.

error: pathspec 'CountWord.c' did not match any file(s) known to git

--- CountWord.c
+++ CountWord.c
@@ -0,0 +1,239 @@
+// Protechsoft.c : Defines the entry point for the console application.
+//
+
+#include "stdafx.h"
+#include <malloc.h>
+
+#define MIN_WORD_LENGTH 2
+#define compare(x, y) (x>y?1:(x<y?-1:0))
+
+typedef struct Node
+{
+	struct Node *next;
+	char word[141];
+	int count;
+} Node;
+
+Node *head = NULL;
+
+int store(char[]);
+int insert(char[], Node *);
+int printList();
+int freeMem();
+
+int main()
+{
+	//Count the number of occurences of each word
+
+	char tweet[142], word[141];
+	//char delims[] = { ' ', '.'}; //TODO: Add custom delimiter support
+	int i, length;
+
+	//Get the word and remove the trailing new line
+	printf("Enter the tweet: ");
+	fgets(tweet, 142, stdin);
+	for (i = 0; tweet[i] != '\n'; ++i);
+	tweet[i] = '\0';
+	length = i;
+
+	//Parse the tweet, recognise words, check if they meet requirements, deal with them accordingly
+	for (i = 0; i < length; ++i)
+	{
+		char current = tweet[i];
+		//if current character is a letter. TODO: Add support for custom word beginnings
+		if (((current >= 'A') && (current <= 'Z')) || ((current >= 'a') && (current <= 'z')))
+		{
+			int j = 0;
+			for (; (i < length) && (tweet[i]!=' ' && tweet[i] != '.'  && tweet[i] != ','); ++i, ++j)	//delimiter support needed
+			{
+				word[j] = tweet[i];
+			}
+			//If word meets minimum length requirements
+			if (j >= MIN_WORD_LENGTH)
+			{
+				word[j] = '\0';
+				store(word);
+			}
+		}
+	}
+
+	printf("\nThe word list with frequency:\n");
+	printList();	//TODO: implement this function
+	freeMem();		//TODO: implement this function
+	return 0;
+}
+
+int store(char word[])
+{
+	if (head == NULL)	//If the list is empty
+	{
+		insert(word, NULL);	//insert at the first position
+		return 1;
+	}
+	Node *next = head;
+	Node *current = NULL;
+	while (next != NULL)
+	{
+		//compare current word to next word in the list
+		int i;
+		int result = -2;
+		int tempResult = -2;	//flag to be used when the first non-alphabetical pair is encountered. refer to point 2c of readme
+
+		for (i = 0; (next->word[i] != '\0') && (word[i] != '\0'); ++i)
+		{
+			result=-2;
+			char c1 = word[i], c2 = next->word[i];
+			if (c1 >= 'A' && c1 <= 'Z')
+			{
+				if (c2 >= 'A' && c2 <= 'Z')
+				{
+					result = compare(c1, c2);
+				}
+				else if (c2 >= 'a' && c2 <= 'z')
+				{
+					result = compare(c1 + 32, c2);	//converting to lower case and comparing
+				}
+				else
+				{
+					result = -1;
+				}
+			}
+			else if (c1 >= 'a' && c1 <= 'z')
+			{
+				if (c2 >= 'a' && c2 <= 'z')
+				{
+					result = compare(c1, c2);
+				}
+				else if (c2 >= 'A' && c2 <= 'Z')
+				{
+					result = compare(c1, c2+32);	//converting to lower case and comparing
+				}
+				else
+				{
+					result = -1;
+				}
+			}
+			else
+			{
+				tempResult = compare(c1, c2);
+			}
+			if (result)
+			{
+				break;
+			}
+		}
+
+		//if the words are of unequal length (If one of them is finished but not both)
+		if (!(word[i]=='\0') != !(next->word[i]=='\0'))
+		{
+			if (next->word[i] == '\0')	//if next word is shorter, it is lexicographically lesser than word
+			{
+				current = next;
+				next = next->next;
+				continue;
+			}
+			else	//if word is shorter than next word, it is lexicographically lesser than the next word
+			{
+				if (next == head)	//if it is the beginning of the list
+				{
+					return insert(word, NULL);
+				}
+				else
+				{
+					return insert(word, current);
+				}
+			}
+		}
+		if (result == -2)	//if nothing was compared
+		{
+			return 0;	//something is VERY wrong
+		}
+
+		//if current word matches exactly with next word. If there were symbols, then they match too
+		if (result == 0 && (tempResult==-2 || tempResult==0) )
+		{
+			return next->count += 1;
+		}
+
+		//if the word is lexicographically lesser. If the letters match then the symbols don't
+		else if (result==-1 || (result == 0 && tempResult == -1 ))
+		{
+			if (next == head)	//If it is the beginning of the list
+			{
+				return insert(word, NULL);
+			}
+			else
+			{
+				return insert(word, current);
+			}
+		}
+
+		//if the word is lexicographically greater. If the letters match, then the symbols don't
+		else if (result == 1 || (result == 0 && tempResult == 1))
+		{
+			current = next;
+			next = next->next;
+			continue;
+		}
+	}
+	insert(word, current);	//if we reached the end of the list
+	return 1;
+}
+
+int insert(char data[], Node *current)
+{
+	int i;
+
+	Node *tempNewNode = (Node *)malloc(sizeof(Node));
+	tempNewNode->count = 1;
+	for (i = 0; data[i] != '\0'; ++i)
+	{
+		tempNewNode->word[i] = data[i];
+	}
+	tempNewNode->word[i] = '\0';
+
+	if (current)	//Insertion at any position except beginning
+	{
+		Node *tempNode = current->next;
+		current->next = tempNewNode;
+		tempNewNode->next = tempNode;
+	}
+	else  //Insertion at the beginning
+	{
+		tempNewNode->next = head;
+		head = tempNewNode;
+	}
+	return 1;
+}
+
+int printList()
+{
+	if (head == NULL)
+	{
+		return 0;
+	}
+	Node *current = head;
+	printf("\n\nThe words and their frequencies:\n");
+	while (current != NULL)
+	{
+		printf("%s %d\n", current->word, current->count);
+		current = current->next;
+	}
+	return 0;
+}
+
+int freeMem()
+{
+	if (head == NULL)
+	{
+		return 0;
+	}
+	Node *tempNode;
+	while (head != NULL)
+	{
+		tempNode = head;
+		head = head->next;
+		free(tempNode);
+	}
+	return 0;
+}


Now uses the BaseTypeFactory class.

Now uses the BaseTypeFactory class.

--- DDXParser.h
+++ DDXParser.h
@@ -44,6 +44,10 @@
 #include "BaseType.h"
 #endif

+#ifndef base_type_factory_h
+#include "BaseTypeFactory.h"
+#endif
+
 /** Parse the XML text which encodes the network/persistent representation of
     the DDX object. In the current implementation, the DDX is held by an
     instance of the class DDS which in turn holds variables which include
@@ -56,13 +60,13 @@
     methods are public because making them private complicates compilation.
     They should not be called by anything other than the \i intern method.
     They do not throw exceptions because exceptions from within callbacks are
-    not reliable or portable (although exceptions themselves are not 100%
-    portable...). To signal errors, the methods record information in the
-    DDXParser object. Once the error handler is called, construction of an
-    DDX/DDS object ends even though the SAX parser still calls the various
-    callback functions. The parser treats \i warnings, \i errors and \i
-    fatal_errors the same way; when any are found parsing stops. The \i
-    intern method throws an DDXParseFailed exception if an error was found.
+    not reliable or portable. To signal errors, the methods record
+    information in the DDXParser object. Once the error handler is called,
+    construction of an DDX/DDS object ends even though the SAX parser still
+    calls the various callback functions. The parser treats \i warnings, \i
+    errors and \i fatal_errors the same way; when any are found parsing
+    stops. The \i intern method throws an DDXParseFailed exception if an
+    error was found.

     Note that this class uses the C++-supplied default definitions for the
     default and copy constructors as well as the destructor and assignment
@@ -102,6 +106,8 @@
 	parser_error
     };

+    BaseTypeFactory *d_factory;
+
     // These stacks hold the state of the parse as it progresses.
     stack<ParseState> s;	// Current parse state
     stack<BaseType*> bt_stack;	// current variable(s)
@@ -125,6 +131,9 @@
     void set_state(DDXParser::ParseState state);
     DDXParser::ParseState get_state();
     void pop_state();
+
+    // Glue for the BaseTypeFactory class.
+    BaseType *factory(Type t, const string &name);

     /** @name Parser Actions

@@ -149,7 +158,12 @@
     void finish_variable(const char *tag, Type t, const char *expected);
     //@}

+    /// Define the default ctor here to prevent its use.
+    DDXParser() {}
+
 public:
+    DDXParser(BaseTypeFactory *factory) : d_factory(factory) {}
+
     void intern(const string &document, DDS *dest_dds, string *blob)
 	throw(DDXParseFailed);

@@ -165,6 +179,9 @@
 };

 // $Log: DDXParser.h,v $
+// Revision 1.7  2005/03/30 21:29:05  jimg
+// Now uses the BaseTypeFactory class.
+//
 // Revision 1.6  2003/12/08 18:02:29  edavis
 // Merge release-3-4 into trunk
 //


making ctcontext work with GL and DX

making ctcontext work with GL and DX

git-svn-id: 0a20d38d1bcdb3210d244a647211d61b0aabf366@151 5b8196f7-c1c0-4be6-8b13-4feed349168d

--- DynamicDX.h
+++ DynamicDX.h
@@ -36,10 +36,11 @@

 #pragma once

-#if defined(_WIN32) && defined(USE_DIRECTX)

 #ifndef DYNAMICDX_H
 #define DYNAMICDX_H
+
+#if defined(_WIN32) && defined(USE_DIRECTX)

 #include "StdDefines.h"

@@ -241,6 +242,11 @@

 };

+
+#else // _WIN32 && USE_DIRECTX
+
+typedef void ID3D10Device;
+
+#endif // _WIN32 && USE_DIRECTX
+
 #endif // DYNAMICDX_H
-
-#endif // _WIN32 && USE_DIRECTX


check return value and print warning message if no messages have been read.

--- hab/libamedevice/amedevice.c
+++ hab/libamedevice/amedevice.c
@@ -253,6 +253,11 @@

     name = malloc(25);
     i = ame_read_command(fd, name, 24);
+    if (0 >= i) {
+	fprintf(stderr, "ame_respoinse_return_name(): No name.");
+	free(name);
+	return NULL;
+    }
     name[24] = '\0';


moved utility function outside the class

git-svn-id: 5398946ba177a3e438c2dae55e2cdfc2fb96c905@642 a9d63959-f2ad-4865-b262-bf0e56cfafb6

--- surface/include/pcl/surface/gp3.h
+++ surface/include/pcl/surface/gp3.h
@@ -52,10 +52,84 @@

 namespace pcl
 {
+
+  /** \brief Returns if a point X is visible from point R (or the origin)
+    * when taking into account the segment between the points S1 and S2
+    * \param X 2D coordinate of the point
+    * \param S1 2D coordinate of the segment's first point
+    * \param S2 2D coordinate of the segment's secont point
+    * \param R 2D coorddinate of the reference point (defaults to 0,0)
+    * \ingroup surface
+    */
+  inline bool
+  isVisible (const Eigen::Vector2f &X, const Eigen::Vector2f &S1, const Eigen::Vector2f &S2,
+             const Eigen::Vector2f &R = Eigen::Vector2f::Zero ())
+  {
+    double a0 = S1[1] - S2[1];
+    double b0 = S2[0] - S1[0];
+    double c0 = S1[0]*S2[1] - S2[0]*S1[1];
+    double a1 = -X[1];
+    double b1 = X[0];
+    double c1 = 0;
+    if (R != Eigen::Vector2f::Zero())
+    {
+      a1 += R[1];
+      b1 -= R[0];
+      c1 = R[0]*X[1] - X[0]*R[1];
+    }
+    double div = a0*b1 - b0*a1;
+    double x = (b0*c1 - b1*c0) / div;
+    double y = (a1*c0 - a0*c1) / div;
+
+    bool intersection_outside_XR;
+    if (R == Eigen::Vector2f::Zero())
+    {
+      if (X[0] > 0)
+        intersection_outside_XR = (x <= 0) || (x >= X[0]);
+      else if (X[0] < 0)
+        intersection_outside_XR = (x >= 0) || (x <= X[0]);
+      else if (X[1] > 0)
+        intersection_outside_XR = (y <= 0) || (y >= X[1]);
+      else if (X[1] < 0)
+        intersection_outside_XR = (y >= 0) || (y <= X[1]);
+      else
+        intersection_outside_XR = true;
+    }
+    else
+    {
+      if (X[0] > R[0])
+        intersection_outside_XR = (x <= R[0]) || (x >= X[0]);
+      else if (X[0] < R[0])
+        intersection_outside_XR = (x >= R[0]) || (x <= X[0]);
+      else if (X[1] > R[1])
+        intersection_outside_XR = (y <= R[1]) || (y >= X[1]);
+      else if (X[1] < R[1])
+        intersection_outside_XR = (y >= R[1]) || (y <= X[1]);
+      else
+        intersection_outside_XR = true;
+    }
+    if (intersection_outside_XR)
+      return true;
+    else
+    {
+      if (S1[0] > S2[0])
+        return (x <= S2[0]) || (x >= S1[0]);
+      else if (S1[0] < S2[0])
+        return (x >= S2[0]) || (x <= S1[0]);
+      else if (S1[1] > S2[1])
+        return (y <= S2[1]) || (y >= S1[1]);
+      else if (S1[1] < S2[1])
+        return (y >= S2[1]) || (y <= S1[1]);
+      else
+        return false;
+    }
+  }
+
   /** \brief GreedyProjectionTriangulation is an implementation of a greedy triangulation algorithm for 3D points
     * based on local 2D projections. It assumes locally smooth surfaces and relatively smooth transitions between
     * areas with different point densities.
     * \author Zoltan Csaba Marton
+    * \ingroup surface
     */
   template <typename PointInT>
   class GreedyProjectionTriangulation : public SurfaceReconstruction<PointInT>
@@ -373,77 +447,6 @@
         else
           return a1.visible;
       }
-
-      /** \brief Returns if a point X is visible from point R when taking into account the
-        * segment S1,S2 (use the print parameter to enable output of debug messages)
-        * \param X 2D coordinate of the point
-        * \param S1 2D coordinate of the segment's first point
-        * \param S2 2D coordinate of the segment's secont point
-        * \param R 2D coorddinate of the reference point (defaults to 0,0)
-        */
-      inline bool
-      isVisible (const Eigen::Vector2f &X, const Eigen::Vector2f &S1, const Eigen::Vector2f &S2,
-                 const Eigen::Vector2f &R = Eigen::Vector2f::Zero ())
-      {
-        double a0 = S1[1] - S2[1];
-        double b0 = S2[0] - S1[0];
-        double c0 = S1[0]*S2[1] - S2[0]*S1[1];
-        double a1 = -X[1];
-        double b1 = X[0];
-        double c1 = 0;
-        if (R != Eigen::Vector2f::Zero())
-        {
-          a1 += R[1];
-          b1 -= R[0];
-          c1 = R[0]*X[1] - X[0]*R[1];
-        }
-        double div = a0*b1 - b0*a1;
-        double x = (b0*c1 - b1*c0) / div;
-        double y = (a1*c0 - a0*c1) / div;
-
-        bool intersection_outside_XR;
-        if (R == Eigen::Vector2f::Zero())
-        {
-          if (X[0] > 0)
-            intersection_outside_XR = (x <= 0) || (x >= X[0]);
-          else if (X[0] < 0)
-            intersection_outside_XR = (x >= 0) || (x <= X[0]);
-          else if (X[1] > 0)
-            intersection_outside_XR = (y <= 0) || (y >= X[1]);
-          else if (X[1] < 0)
-            intersection_outside_XR = (y >= 0) || (y <= X[1]);
-          else
-            intersection_outside_XR = true;
-        }
-        else
-        {
-          if (X[0] > R[0])
-            intersection_outside_XR = (x <= R[0]) || (x >= X[0]);
-          else if (X[0] < R[0])
-            intersection_outside_XR = (x >= R[0]) || (x <= X[0]);
-          else if (X[1] > R[1])
-            intersection_outside_XR = (y <= R[1]) || (y >= X[1]);
-          else if (X[1] < R[1])
-            intersection_outside_XR = (y >= R[1]) || (y <= X[1]);
-          else
-            intersection_outside_XR = true;
-        }
-        if (intersection_outside_XR)
-          return true;
-        else
-        {
-          if (S1[0] > S2[0])
-            return (x <= S2[0]) || (x >= S1[0]);
-          else if (S1[0] < S2[0])
-            return (x >= S2[0]) || (x <= S1[0]);
-          else if (S1[1] > S2[1])
-            return (y <= S2[1]) || (y >= S1[1]);
-          else if (S1[1] < S2[1])
-            return (y >= S2[1]) || (y <= S1[1]);
-          else
-            return false;
-        }
-      }
   };

 } // namespace pcl


mls test

mls test

git-svn-id: 1af002208e930b4d920e7c2b948d1e98a012c795@6418 a9d63959-f2ad-4865-b262-bf0e56cfafb6

--- surface/include/pcl/surface/mls.h
+++ surface/include/pcl/surface/mls.h
@@ -322,7 +322,7 @@
         */
       struct MLSResult
       {
-        MLSResult () : plane_normal (), u (), v (), c_vec (), num_neighbors (),  curvature (), valid (false) {}
+        MLSResult () : plane_normal (), u (), v (), c_vec (), num_neighbors (), curvature (), valid (false) {}

         MLSResult (Eigen::Vector3d &a_plane_normal,
                    Eigen::Vector3d &a_u,
@@ -392,7 +392,7 @@
               point[i] = static_cast<Eigen::Vector3f::Scalar> (index_3d[i]) * voxel_size_ + bounding_min_[i];
           }

-          typedef boost::unordered_map<uint64_t, Leaf, boost::hash<uint64_t>, std::equal_to<uint64_t>, Eigen::aligned_allocator<uint64_t> > HashMap;
+          typedef boost::unordered_map<uint64_t, Leaf> HashMap;//, boost::hash<uint64_t>, std::equal_to<uint64_t>, Eigen::aligned_allocator<uint64_t> > HashMap;
           HashMap voxel_grid_;
           Eigen::Vector4f bounding_min_, bounding_max_;
           uint64_t data_size_;


Size show fix

Size show fix

--- plot/include/plot/plot.h
+++ plot/include/plot/plot.h
@@ -221,7 +221,7 @@
     Plot &SetSize( size_t width, size_t height )
     {
         mStream << "\nfig = plt.gcf()\ndpi = fig.get_dpi()\nfig.set_size_inches("
-                << width << "/float(dpi)," << height << "/float(dpi))";
+                << width << "/float(dpi)," << height << "/float(dpi), forward=True)";

         return *this;
     }


Add -r support to crlutil for multiple iterations

--- security/nss/cmd/crlutil/crlutil.c
+++ security/nss/cmd/crlutil/crlutil.c
@@ -289,6 +289,7 @@
     fprintf(stderr, "%-20s \t 1 - SEC_CRL_TYPE\n", " ");
     fprintf(stderr, "\n%-20s Bypass CA certificate checks.\n", "-B");
     fprintf(stderr, "\n%-20s Partial decode for faster operation.\n", "-p");
+    fprintf(stderr, "%-20s Repeat the operation.\n", "-r <iterations>");

     exit(-1);
 }
@@ -315,6 +316,8 @@
     PRInt32 importOptions = CRL_IMPORT_DEFAULT_OPTIONS;
     PRBool test = PR_FALSE;
     PRBool erase = PR_FALSE;
+    PRInt32 i = 0;
+    PRInt32 iterations = 1;

     progName = strrchr(argv[0], '/');
     progName = progName ? progName+1 : argv[0];
@@ -330,7 +333,7 @@
     /*
      * Parse command line arguments
      */
-    optstate = PL_CreateOptState(argc, argv, "BCDILP:d:i:n:pt:u:TE");
+    optstate = PL_CreateOptState(argc, argv, "BCDILP:d:i:n:pt:u:TEr:");
     while ((status = PL_GetNextOpt(optstate)) == PL_OPT_OK) {
 	switch (optstate->option) {
 	  case '?':
@@ -389,6 +392,13 @@

 	  case 'p':
 	    decodeOptions |= CRL_DECODE_SKIP_ENTRIES;
+	    break;
+
+	  case 'r': {
+	      const char* str = optstate->value;
+	      if (str && atoi(str)>0)
+		iterations = atoi(str);
+	    }
 	    break;

 	  case 't': {
@@ -429,34 +439,34 @@
 	return (-1);
     }

-    /* Read in the private key info */
-    if (deleteCRL)
-	DeleteCRL (certHandle, nickName, crlType);
-    else if (listCRL) {
-	int i = 0;
-	for (i=0; i<10; i++)
+    for (i=0; i<iterations; i++) {
+	/* Read in the private key info */
+	if (deleteCRL)
+	    DeleteCRL (certHandle, nickName, crlType);
+	else if (listCRL) {
 	    ListCRL (certHandle, nickName, crlType);
-    }
-    else if (importCRL) {
-	rv = ImportCRL (certHandle, url, crlType, inFile, importOptions,
-                        decodeOptions);
-    }
-    else if (erase) {
-        /* list and delete all CRLs */
-        ListCRLNames (certHandle, crlType, PR_TRUE);
-    }
+	}
+	else if (importCRL) {
+	    rv = ImportCRL (certHandle, url, crlType, inFile, importOptions,
+			    decodeOptions);
+	}
+	else if (erase) {
+	    /* list and delete all CRLs */
+	    ListCRLNames (certHandle, crlType, PR_TRUE);
+	}
 #ifdef DEBUG
-    else if (test) {
-        /* list and delete all CRLs */
-        ListCRLNames (certHandle, crlType, PR_TRUE);
-        /* list CRLs */
-        ListCRLNames (certHandle, crlType, PR_FALSE);
-        /* import CRL as a blob */
-	rv = ImportCRL (certHandle, url, crlType, inFile, importOptions,
-                        decodeOptions);
-        /* list CRLs */
-        ListCRLNames (certHandle, crlType, PR_FALSE);
-    }
+	else if (test) {
+	    /* list and delete all CRLs */
+	    ListCRLNames (certHandle, crlType, PR_TRUE);
+	    /* list CRLs */
+	    ListCRLNames (certHandle, crlType, PR_FALSE);
+	    /* import CRL as a blob */
+	    rv = ImportCRL (certHandle, url, crlType, inFile, importOptions,
+			    decodeOptions);
+	    /* list CRLs */
+	    ListCRLNames (certHandle, crlType, PR_FALSE);
+	}
 #endif
+    }
     return (rv);
 }


another attempt to fix builds, function needs to be forward declared

--- security/nss/lib/softoken/dbinit.c
+++ security/nss/lib/softoken/dbinit.c
@@ -187,6 +187,9 @@
       CERT_SetDefaultCertDB(&certhandle);
       return CKR_OK;
 }
+
+/* forward declare so that a failure in the init case can shutdown */
+void pk11_Shutdown(void);

 /*
  * OK there are now lots of options here, lets go through them all:


Bump softoken version to 3.7 on tip

Bump softoken version to 3.7 on tip

--- security/nss/lib/softoken/pkcs11.c
+++ security/nss/lib/softoken/pkcs11.c
@@ -2652,7 +2652,7 @@
     pInfo->cryptokiVersion.minor = 11;
     PORT_Memcpy(pInfo->manufacturerID,manufacturerID,32);
     pInfo->libraryVersion.major = 3;
-    pInfo->libraryVersion.minor = 6;
+    pInfo->libraryVersion.minor = 7;
     PORT_Memcpy(pInfo->libraryDescription,libraryDescription,32);
     pInfo->flags = 0;
     return CKR_OK;
@@ -2693,7 +2693,7 @@
     /* ok we really should read it out of the keydb file. */
     /* pInfo->hardwareVersion.major = NSSLOWKEY_DB_FILE_VERSION; */
     pInfo->hardwareVersion.major = 3;
-    pInfo->hardwareVersion.minor = 6;
+    pInfo->hardwareVersion.minor = 7;
     return CKR_OK;
 }


cleanup

cleanup

--- media/dosamp/dosamp.c
+++ media/dosamp/dosamp.c
@@ -42,6 +42,8 @@
     uint16_t    wBitsPerSample;         /* +14 */
 } windows_WAVEFORMATPCM;                /* =16 */
 #pragma pack(pop)
+
+#define windows_WAVE_FORMAT_PCM         0x0001

 /* this code won't work with the TINY memory model for awhile. sorry. */
 #ifdef __TINY__
@@ -325,6 +327,17 @@
 static dosamp_file_source_t             wav_source = NULL;

 static char*                            wav_file = NULL;
+
+struct wav_cbr_t {
+    uint32_t                            sample_rate;
+    uint16_t                            number_of_channels;
+    uint16_t                            bits_per_sample;
+    uint16_t                            bytes_per_block;
+    uint16_t                            samples_per_block;
+};
+
+struct wav_cbr_t                        file_codec;
+struct wav_cbr_t                        play_codec;

 static unsigned char                    wav_stereo = 0,wav_16bit = 0,wav_bytes_per_sample = 1;
 static unsigned long                    wav_data_offset = 44,wav_data_length = 0,wav_sample_rate = 8000,wav_position = 0,wav_buffer_filepos = 0;
@@ -618,10 +631,29 @@
                     if (wav_source->read(wav_source,tmp,len) == len) {
                         windows_WAVEFORMATPCM *wfx = (windows_WAVEFORMATPCM*)tmp;

-                        wav_sample_rate = le32toh(wfx->nSamplesPerSec);
-                        wav_stereo = le16toh(wfx->nChannels) > 1;
-                        wav_16bit = le16toh(wfx->wBitsPerSample) > 8;
-                        wav_bytes_per_sample = (wav_stereo ? 2 : 1) * (wav_16bit ? 2 : 1);
+                        wav_sample_rate = 0;
+
+                        file_codec.number_of_channels = le16toh(wfx->nChannels);
+                        file_codec.bits_per_sample = le16toh(wfx->wBitsPerSample);
+                        file_codec.sample_rate = le32toh(wfx->nSamplesPerSec);
+                        file_codec.bytes_per_block = le16toh(wfx->nBlockAlign);
+                        file_codec.samples_per_block = 1;
+
+                        if (file_codec.sample_rate >= 1000UL && file_codec.sample_rate <= 96000UL) {
+                            if (le16toh(wfx->wFormatTag) == windows_WAVE_FORMAT_PCM) {
+                                if ((file_codec.bits_per_sample >= 8U && file_codec.bits_per_sample <= 16U) &&
+                                    (file_codec.number_of_channels >= 1U && file_codec.number_of_channels <= 2U)) {
+                                    file_codec.bytes_per_block =
+                                        ((file_codec.bits_per_sample + 7U) >> 3U) *
+                                        file_codec.number_of_channels;
+
+                                    wav_sample_rate = file_codec.sample_rate;
+                                    wav_stereo = file_codec.number_of_channels > 1;
+                                    wav_16bit = file_codec.bits_per_sample > 8;
+                                    wav_bytes_per_sample = file_codec.bytes_per_block;
+                                }
+                            }
+                        }
                     }
                 }
             }
@@ -750,8 +782,10 @@
 }

 static void update_cfg() {
-    sb_card->dsp_adpcm = 0;
     sb_card->buffer_irq_interval = sb_card->buffer_size / wav_bytes_per_sample;
+
+    /* TODO: at some point we'll support on-the-fly conversion to what the sound card supports */
+    play_codec = file_codec;
 }

 static void help() {


rpcd: Implement rpcd_service_unregister(), fix warnings.

--- tools/rpcd/src/main.c
+++ tools/rpcd/src/main.c
@@ -161,7 +161,14 @@
 static rpc_object_t
 rpcd_service_unregister(void *cookie, rpc_object_t args)
 {
-
+	struct rpcd_service *service;
+
+	service = rpc_function_get_arg(cookie);
+	rpc_context_unregister_instance(rpcd_context,
+	    rpc_instance_get_path(service->instance));
+
+	g_hash_table_remove(rpcd_services, service->name);
+	return (NULL);
 }

 static rpc_object_t
@@ -230,21 +237,21 @@
 	for (dirname = rpcd_service_dirs; *dirname != NULL; (*dirname)++) {
 		syslog(LOG_NOTICE, "Loading services from %s", *dirname);
 		dir = g_dir_open(*dirname, 0, &err);
-		if (dir == NULL) {
+		if (dir == NULL)
 			continue;
-		}

 		for (;;) {
 			name = g_dir_read_name(dir);
 			if (name == NULL)
 				break;

-
 			path = g_build_filename(*dirname, name, NULL);
 			rpcd_load_service(path);
 			g_free(path);
 		}
 	}
+
+	return (0);
 }

 int


[memaccess] Fix formating

[memaccess] Fix formating

--- memaccess/memaccess.h
+++ memaccess/memaccess.h
@@ -85,19 +85,16 @@
         memory_address_t address, bool *region_available,
         memory_region_t *memory_region);

-
 /**
  * Copies a chunk of memory from the process' address space to the buffer.
  *
  * Note that start_address is the address as seen by the process.
- *
  * If no fatal error ocurred the buffer will be populated with bytes_read bytes.
- *
  * It's caller's responsibility to provide a big enough buffer.
  **/
 response_t *copy_process_memory(process_handle_t handle,
-                                memory_address_t start_address, size_t bytes_to_read, void *buffer,
-                                size_t *bytes_read);
+        memory_address_t start_address, size_t bytes_to_read, void *buffer,
+        size_t *bytes_read);

 #endif /* MEMACCES_H */


Add API for query the number of training classes.

--- Xcode/ESP/src/training-data-manager.h
+++ Xcode/ESP/src/training-data-manager.h
@@ -52,6 +52,8 @@
     GRT::TimeSeriesClassificationData getAllData() { return data_; }

     uint32_t getNumLabels() { return num_classes_; }
+
+    uint32_t getTotalNumSamples() { return data_.getNumSamples(); }

     // =================================================
     //  Functions that enables per-sample naming


added Point3d property

added Point3d property

--- Core/DataStructures/mitkProperties.h
+++ Core/DataStructures/mitkProperties.h
@@ -2,9 +2,17 @@
 #define MITKPROPERTIES_H_HEADER_INCLUDED

 #include "mitkGenericProperty.h"
+#include "vecmath.h"

 namespace mitk {
    typedef GenericProperty<int> IntProperty;
    template class GenericProperty<int>;
+
+   typedef GenericProperty<Point3d> Point3dProperty;
+   template class GenericProperty<Point3d>;
+
+//   typedef GenericProperty<int> IntProperty;
+//   template class GenericProperty<int>;
+
 }  // namespace mitk
 #endif /* MITKPROPERTIES_H_HEADER_INCLUDED */


Fixed missing character in signet usage

Fixed missing character in signet usage

--- tools/signet/signet.c
+++ tools/signet/signet.c
@@ -10,7 +10,7 @@
 */
 static void usage(const char *progname) {

-	fprintf(stderr, "\nUsage: %s <-g signet_id> <-s signet_id> <-d signet_filename> [-o output_filename] [-k keys_filename] [-r ssr_filename] [-c custody_filename] <-x signet_type\n", progname);
+	fprintf(stderr, "\nUsage: %s <-g signet_id> <-s signet_id> <-d signet_filename> [-o output_filename] [-k keys_filename] [-r ssr_filename] [-c custody_filename] <-x signet_type>\n", progname);
 	fprintf(stderr, "  --generate|-g   Uses provided signet id to generate a signet or SSR (signet signing request) and a keys files, may be used with a -c option to create an SSR for rotation of user signets.\n");
 	fprintf(stderr, "  --sign    |-s   Signs an SSR file specifed by the -r option with an org signing key specified by -k option and creates a user signet file.\n");
 	fprintf(stderr, "  --dump    |-d   Specifies filename of a signet file, the contents of which are dumped to the terminal.\n");


drbd: Allow packet handler functions that take a connection

That is necessary in case a connection does not have a volume 0

Signed-off-by: Philipp Reisner <35a55a4ac466b5abd81eb66f3f7d6a972dd0dc24@linbit.com>
Signed-off-by: Lars Ellenberg <31df9cacdc65c624cc60c2dcd22bbf92dc230e16@linbit.com>

--- drivers/block/drbd/drbd_receiver.c
+++ drivers/block/drbd/drbd_receiver.c
@@ -3853,39 +3853,45 @@
 	return true;
 }

-typedef int (*drbd_cmd_handler_f)(struct drbd_conf *, enum drbd_packet cmd,
-				  unsigned int to_receive);
-
 struct data_cmd {
 	int expect_payload;
 	size_t pkt_size;
-	drbd_cmd_handler_f function;
+	enum {
+		MDEV,
+		CONN,
+	} type;
+	union {
+		int (*mdev_fn)(struct drbd_conf *, enum drbd_packet cmd,
+				  unsigned int to_receive);
+		int (*conn_fn)(struct drbd_tconn *, enum drbd_packet cmd,
+				  unsigned int to_receive);
+	};
 };

 static struct data_cmd drbd_cmd_handler[] = {
-	[P_DATA]	    = { 1, sizeof(struct p_data), receive_Data },
-	[P_DATA_REPLY]	    = { 1, sizeof(struct p_data), receive_DataReply },
-	[P_RS_DATA_REPLY]   = { 1, sizeof(struct p_data), receive_RSDataReply } ,
-	[P_BARRIER]	    = { 0, sizeof(struct p_barrier), receive_Barrier } ,
-	[P_BITMAP]	    = { 1, sizeof(struct p_header), receive_bitmap } ,
-	[P_COMPRESSED_BITMAP] = { 1, sizeof(struct p_header), receive_bitmap } ,
-	[P_UNPLUG_REMOTE]   = { 0, sizeof(struct p_header), receive_UnplugRemote },
-	[P_DATA_REQUEST]    = { 0, sizeof(struct p_block_req), receive_DataRequest },
-	[P_RS_DATA_REQUEST] = { 0, sizeof(struct p_block_req), receive_DataRequest },
-	[P_SYNC_PARAM]	    = { 1, sizeof(struct p_header), receive_SyncParam },
-	[P_SYNC_PARAM89]    = { 1, sizeof(struct p_header), receive_SyncParam },
-	[P_PROTOCOL]        = { 1, sizeof(struct p_protocol), receive_protocol },
-	[P_UUIDS]	    = { 0, sizeof(struct p_uuids), receive_uuids },
-	[P_SIZES]	    = { 0, sizeof(struct p_sizes), receive_sizes },
-	[P_STATE]	    = { 0, sizeof(struct p_state), receive_state },
-	[P_STATE_CHG_REQ]   = { 0, sizeof(struct p_req_state), receive_req_state },
-	[P_SYNC_UUID]       = { 0, sizeof(struct p_rs_uuid), receive_sync_uuid },
-	[P_OV_REQUEST]      = { 0, sizeof(struct p_block_req), receive_DataRequest },
-	[P_OV_REPLY]        = { 1, sizeof(struct p_block_req), receive_DataRequest },
-	[P_CSUM_RS_REQUEST] = { 1, sizeof(struct p_block_req), receive_DataRequest },
-	[P_DELAY_PROBE]     = { 0, sizeof(struct p_delay_probe93), receive_skip },
-	[P_OUT_OF_SYNC]     = { 0, sizeof(struct p_block_desc), receive_out_of_sync },
-	[P_CONN_ST_CHG_REQ] = { 0, sizeof(struct p_req_state), receive_req_state },
+	[P_DATA]	    = { 1, sizeof(struct p_data), MDEV, { receive_Data } },
+	[P_DATA_REPLY]	    = { 1, sizeof(struct p_data), MDEV, { receive_DataReply } },
+	[P_RS_DATA_REPLY]   = { 1, sizeof(struct p_data), MDEV, { receive_RSDataReply } } ,
+	[P_BARRIER]	    = { 0, sizeof(struct p_barrier), MDEV, { receive_Barrier } } ,
+	[P_BITMAP]	    = { 1, sizeof(struct p_header), MDEV, { receive_bitmap } } ,
+	[P_COMPRESSED_BITMAP] = { 1, sizeof(struct p_header), MDEV, { receive_bitmap } } ,
+	[P_UNPLUG_REMOTE]   = { 0, sizeof(struct p_header), MDEV, { receive_UnplugRemote } },
+	[P_DATA_REQUEST]    = { 0, sizeof(struct p_block_req), MDEV, { receive_DataRequest } },
+	[P_RS_DATA_REQUEST] = { 0, sizeof(struct p_block_req), MDEV, { receive_DataRequest } },
+	[P_SYNC_PARAM]	    = { 1, sizeof(struct p_header), MDEV, { receive_SyncParam } },
+	[P_SYNC_PARAM89]    = { 1, sizeof(struct p_header), MDEV, { receive_SyncParam } },
+	[P_PROTOCOL]        = { 1, sizeof(struct p_protocol), MDEV, { receive_protocol } },
+	[P_UUIDS]	    = { 0, sizeof(struct p_uuids), MDEV, { receive_uuids } },
+	[P_SIZES]	    = { 0, sizeof(struct p_sizes), MDEV, { receive_sizes } },
+	[P_STATE]	    = { 0, sizeof(struct p_state), MDEV, { receive_state } },
+	[P_STATE_CHG_REQ]   = { 0, sizeof(struct p_req_state), MDEV, { receive_req_state } },
+	[P_SYNC_UUID]       = { 0, sizeof(struct p_rs_uuid), MDEV, { receive_sync_uuid } },
+	[P_OV_REQUEST]      = { 0, sizeof(struct p_block_req), MDEV, { receive_DataRequest } },
+	[P_OV_REPLY]        = { 1, sizeof(struct p_block_req), MDEV, { receive_DataRequest } },
+	[P_CSUM_RS_REQUEST] = { 1, sizeof(struct p_block_req), MDEV, { receive_DataRequest } },
+	[P_DELAY_PROBE]     = { 0, sizeof(struct p_delay_probe93), MDEV, { receive_skip } },
+	[P_OUT_OF_SYNC]     = { 0, sizeof(struct p_block_desc), MDEV, { receive_out_of_sync } },
+	[P_CONN_ST_CHG_REQ] = { 0, sizeof(struct p_req_state), MDEV, { receive_req_state } },
 };

 /* All handler functions that expect a sub-header get that sub-heder in
@@ -3898,7 +3904,6 @@
 static void drbdd(struct drbd_tconn *tconn)
 {
 	struct p_header *header = &tconn->data.rbuf.header;
-	struct drbd_conf *mdev;
 	struct packet_info pi;
 	size_t shs; /* sub header size */
 	int rv;
@@ -3909,7 +3914,7 @@
 			goto err_out;

 		if (unlikely(pi.cmd >= ARRAY_SIZE(drbd_cmd_handler) ||
-		    !drbd_cmd_handler[pi.cmd].function)) {
+		    !drbd_cmd_handler[pi.cmd].mdev_fn)) {
 			conn_err(tconn, "unknown packet type %d, l: %d!\n", pi.cmd, pi.size);
 			goto err_out;
 		}
@@ -3929,10 +3934,14 @@
 			}
 		}

-		mdev = vnr_to_mdev(tconn, pi.vnr);
-		rv = mdev ?
-			drbd_cmd_handler[pi.cmd].function(mdev, pi.cmd, pi.size - shs) :
-			tconn_receive_skip(tconn, pi.cmd, pi.size - shs);
+		if (drbd_cmd_handler[pi.cmd].type == CONN) {
+			rv = drbd_cmd_handler[pi.cmd].conn_fn(tconn, pi.cmd, pi.size - shs);
+		} else {
+			struct drbd_conf *mdev = vnr_to_mdev(tconn, pi.vnr);
+			rv = mdev ?
+				drbd_cmd_handler[pi.cmd].mdev_fn(mdev, pi.cmd, pi.size - shs) :
+				tconn_receive_skip(tconn, pi.cmd, pi.size - shs);
+		}

 		if (unlikely(!rv)) {
 			conn_err(tconn, "error receiving %s, l: %d!\n",


cpufreq: governor: Remove fossil comment in the cpufreq_governor_dbs()

The related code has been changed and the comment is out of date.
So remove it.

Signed-off-by: Lan Tianyu <4221d0916eb5c472a0ab46f0107445bbb3e8a589@intel.com>
Acked-by: Viresh Kumar <5ff32272b3d9f86512eddc8e0af523fc6f7924e5@linaro.org>
Signed-off-by: Rafael J. Wysocki <27ffc44a8ec6a212fba98cfc3246c6ce8ab131e0@intel.com>
Git-commit: aae467c79b14db0d286764ed9ddbaefe3715ebd2
Git-repo: git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
Signed-off-by: Junjie Wu <bb05168246ed1a6b66d0e7b1ffb0c5e3707764ca@codeaurora.org>

--- drivers/cpufreq/cpufreq_governor.c
+++ drivers/cpufreq/cpufreq_governor.c
@@ -328,10 +328,6 @@
 					     dbs_data->cdata->gov_dbs_timer);
 		}

-		/*
-		 * conservative does not implement micro like ondemand
-		 * governor, thus we are bound to jiffes/HZ
-		 */
 		if (dbs_data->cdata->governor == GOV_CONSERVATIVE) {
 			cs_dbs_info->down_skip = 0;
 			cs_dbs_info->enable = 1;


cpufreq: ondemand: Eliminate the deadband effect

Currently, ondemand calculates the target frequency proportional to load
using the formula:
	Target frequency = C * load
	where C = policy->cpuinfo.max_freq / 100

Though, in many cases, the minimum available frequency is pretty high and
the above calculation introduces a dead band from load 0 to
100 * policy->cpuinfo.min_freq / policy->cpuinfo.max_freq where the target
frequency is always calculated to less than policy->cpuinfo.min_freq and
the minimum frequency is selected.

For example: on Intel i7-3770 @ 3.4GHz the policy->cpuinfo.min_freq = 1600000
and the policy->cpuinfo.max_freq = 3400000 (without turbo). Thus, the CPU
starts to scale up at a load above 47.
On quad core 1500MHz Krait the policy->cpuinfo.min_freq = 384000
and the policy->cpuinfo.max_freq = 1512000. Thus, the CPU starts to scale
at load above 25.

Change the calculation of target frequency to eliminate the above effect using
the formula:

	Target frequency = A + B * load
	where A = policy->cpuinfo.min_freq and
	      B = (policy->cpuinfo.max_freq - policy->cpuinfo->min_freq) / 100

This will map load values 0 to 100 linearly to cpuinfo.min_freq to
cpuinfo.max_freq.

Also, use the CPUFREQ_RELATION_C in __cpufreq_driver_target to select the
closest frequency in frequency_table. This is necessary to avoid selection
of minimum frequency only when load equals to 0. It will also help for selection
of frequencies using a more 'fair' criterion.

Tables below show the difference in selected frequency for specific values
of load without and with this patch. On Intel i7-3770 @ 3.40GHz:
	Without			With
Load	Target	Selected	Target	Selected
0	0	1600000		1600000	1600000
5	170050	1600000		1690050	1700000
10	340100	1600000		1780100	1700000
15	510150	1600000		1870150	1900000
20	680200	1600000		1960200	2000000
25	850250	1600000		2050250	2100000
30	1020300	1600000		2140300	2100000
35	1190350	1600000		2230350	2200000
40	1360400	1600000		2320400	2400000
45	1530450	1600000		2410450	2400000
50	1700500	1900000		2500500	2500000
55	1870550	1900000		2590550	2600000
60	2040600	2100000		2680600	2600000
65	2210650	2400000		2770650	2800000
70	2380700	2400000		2860700	2800000
75	2550750	2600000		2950750	3000000
80	2720800	2800000		3040800	3000000
85	2890850	2900000		3130850	3100000
90	3060900	3100000		3220900	3300000
95	3230950	3300000		3310950	3300000
100	3401000	3401000		3401000	3401000

On ARM quad core 1500MHz Krait:
	Without			With
Load	Target	Selected	Target	Selected
0	0	384000		384000	384000
5	75600	384000		440400	486000
10	151200	384000		496800	486000
15	226800	384000		553200	594000
20	302400	384000		609600	594000
25	378000	384000		666000	702000
30	453600	486000		722400	702000
35	529200	594000		778800	810000
40	604800	702000		835200	810000
45	680400	702000		891600	918000
50	756000	810000		948000	918000
55	831600	918000		1004400	1026000
60	907200	918000		1060800	1026000
65	982800	1026000		1117200	1134000
70	1058400	1134000		1173600	1134000
75	1134000	1134000		1230000	1242000
80	1209600	1242000		1286400	1242000
85	1285200	1350000		1342800	1350000
90	1360800	1458000		1399200	1350000
95	1436400	1458000		1455600	1458000
100	1512000	1512000		1512000	1512000

Tested on Intel i7-3770 CPU @ 3.40GHz and on ARM quad core 1500MHz Krait
(Android smartphone).
Benchmarks on Intel i7 shows a performance improvement on low and medium
work loads with lower power consumption. Specifics:

Phoronix Linux Kernel Compilation 3.1:
Time: -0.40%, energy: -0.07%
Phoronix Apache:
Time: -4.98%, energy: -2.35%
Phoronix FFMPEG:
Time: -6.29%, energy: -4.02%

Also, running mp3 decoding (very low load) shows no differences with and
without this patch.

Signed-off-by: Stratos Karafotis <7d26b35203412f18a7dea4f8e1db1a75b1c5b706@semaphore.gr>
Signed-off-by: Rafael J. Wysocki <27ffc44a8ec6a212fba98cfc3246c6ce8ab131e0@intel.com>

--- drivers/cpufreq/cpufreq_ondemand.c
+++ drivers/cpufreq/cpufreq_ondemand.c
@@ -170,21 +170,24 @@
 		dbs_freq_increase(policy, policy->max);
 	} else {
 		/* Calculate the next frequency proportional to load */
-		unsigned int freq_next;
-		freq_next = load * policy->cpuinfo.max_freq / 100;
+		unsigned int freq_next, min_f, max_f;
+
+		min_f = policy->cpuinfo.min_freq;
+		max_f = policy->cpuinfo.max_freq;
+		freq_next = min_f + load * (max_f - min_f) / 100;

 		/* No longer fully busy, reset rate_mult */
 		dbs_info->rate_mult = 1;

 		if (!od_tuners->powersave_bias) {
 			__cpufreq_driver_target(policy, freq_next,
-					CPUFREQ_RELATION_L);
+					CPUFREQ_RELATION_C);
 			return;
 		}

 		freq_next = od_ops.powersave_bias_target(policy, freq_next,
 					CPUFREQ_RELATION_L);
-		__cpufreq_driver_target(policy, freq_next, CPUFREQ_RELATION_L);
+		__cpufreq_driver_target(policy, freq_next, CPUFREQ_RELATION_C);
 	}
 }


drm/radeon: fix backend map setup on 1 RB sumo boards

Need to adjust the backend map depending on which
RB is enabled.

Fixes:
https://bugzilla.redhat.com/show_bug.cgi?id=892233

Reported-by: Mikko Tiihonen <8419df5dac348e7a3672081286e2dddd60408eb7@iki.fi>
Signed-off-by: Alex Deucher <08dc22c6156113f2deff178e35e3ed9b24d6af9e@amd.com>
Cc: 4fbacc2fa0ffdbb11bf1ad6925b886ebd08dd15f@vger.kernel.org

--- drivers/gpu/drm/radeon/evergreen.c
+++ drivers/gpu/drm/radeon/evergreen.c
@@ -2044,9 +2044,20 @@
 	WREG32(HDP_ADDR_CONFIG, gb_addr_config);
 	WREG32(DMA_TILING_CONFIG, gb_addr_config);

-	tmp = gb_addr_config & NUM_PIPES_MASK;
-	tmp = r6xx_remap_render_backend(rdev, tmp, rdev->config.evergreen.max_backends,
-					EVERGREEN_MAX_BACKENDS, disabled_rb_mask);
+	if ((rdev->config.evergreen.max_backends == 1) &&
+	    (rdev->flags & RADEON_IS_IGP)) {
+		if ((disabled_rb_mask & 3) == 1) {
+			/* RB0 disabled, RB1 enabled */
+			tmp = 0x11111111;
+		} else {
+			/* RB1 disabled, RB0 enabled */
+			tmp = 0x00000000;
+		}
+	} else {
+		tmp = gb_addr_config & NUM_PIPES_MASK;
+		tmp = r6xx_remap_render_backend(rdev, tmp, rdev->config.evergreen.max_backends,
+						EVERGREEN_MAX_BACKENDS, disabled_rb_mask);
+	}
 	WREG32(GB_BACKEND_MAP, tmp);

 	WREG32(CGTS_SYS_TCC_DISABLE, 0);


drm/radeon/audio: don't set speaker allocation on DCE3.2

It causes hangs on some asics.

Bug:
https://bugs.freedesktop.org/show_bug.cgi?id=70439

Signed-off-by: Alex Deucher <08dc22c6156113f2deff178e35e3ed9b24d6af9e@amd.com>
Reviewed-by: Christian König <c7ea837d7a46effe4232b086213468b8b31643bf@amd.com>

--- drivers/gpu/drm/radeon/r600_hdmi.c
+++ drivers/gpu/drm/radeon/r600_hdmi.c
@@ -309,6 +309,9 @@
 	u8 *sadb;
 	int sad_count;

+	/* XXX: setting this register causes hangs on some asics */
+	return;
+
 	list_for_each_entry(connector, &encoder->dev->mode_config.connector_list, head) {
 		if (connector->encoder == encoder)
 			radeon_connector = to_radeon_connector(connector);


drivers/include/periph/flashpage.h: add flashpage_write_raw

--- drivers/include/periph/flashpage.h
+++ drivers/include/periph/flashpage.h
@@ -1,5 +1,6 @@
 /*
  * Copyright (C) 2016 Freie Universität Berlin
+ *               2017 Inria
  *
  * This file is subject to the terms and conditions of the GNU Lesser
  * General Public License v2.1. See the file LICENSE in the top level
@@ -28,6 +29,9 @@
  * @brief       Low-level flash page peripheral driver interface
  *
  * @author      Hauke Petersen <hauke.petersen@fu-berlin.de>
+ * @author      Kaspar Schleiser <kaspar@schleiser.de>
+ * @author      Francisco Acosta <francisco.acosta@inria.fr>
+ *
  */

 #ifndef PERIPH_FLASHPAGE_H
@@ -47,8 +51,30 @@
 #ifndef CPU_FLASH_BASE
 #define CPU_FLASH_BASE      (0)
 #endif
+/**
+ * @def     FLASHPAGE_RAW_BLOCKSIZE
+ *
+ * @brief   For raw writings to the flash, this constant must define the
+ *          minimum write length allowed by the MCU.
+ */
+#ifdef DOXYGEN
+#define FLASHPAGE_RAW_BLOCKSIZE
+#endif

 /**
+ * @def     FLASHPAGE_RAW_ALIGNMENT
+ *
+ * @brief   The buffers to be written to the flash MUST be aligned, as well as
+ *          the address on which the buffer is written to the flash. This variable
+ *          must be defined for that purpose, according to the MCU align
+ *          requirements.
+ */
+#ifdef DOXYGEN
+#define FLASHPAGE_RAW_ALIGNMENT
+#endif
+/**
+ * @def FLASHPAGE_SIZE
+ *
  * @brief   Make sure the page size and the number of pages is defined
  */
 #ifndef FLASHPAGE_SIZE
@@ -101,16 +127,39 @@
  * @brief   Write the given page with the given data
  *
  * @param[in] page      page to write
- * @param[in] data      data to write to the page, MUST be @p FLASHPAGE_SIZE
+ * @param[in] data      data to write to the page, MUST be FLASHPAGE_SIZE
  *                      byte. Set to NULL for page erase only.
  */
 void flashpage_write(int page, void *data);

 /**
+ * @brief   Write any number of data bytes to a given location in the
+ *          flash memory
+ *
+ * @warning Make sure the targeted memory area is erased before calling
+ *          this function
+ *
+ * Both target address and data address must be aligned to
+ * FLASHPAGE_RAW_ALIGN. @p len must be a multiple of FLASHPAGE_RAW_BLOCKSIZE.
+ * This function doesn't erase any area in flash, thus be sure the targeted
+ * memory area is erased before writing on it (using the flashpage_write function).
+ *
+ * @param[in] target_addr   address in flash to write to. MUST be aligned
+ *                          to FLASHPAGE_RAW_ALIGNMENT.
+ * @param[in] data          data to write to the address. MUST be aligned
+ *                          to FLASHPAGE_RAW_ALIGNMENT.
+ * @param[in] len           length of the data to be written. It MUST be
+ *                          multiple of FLASHPAGE_RAW_BLOCKSIZE. Also,
+ *                          ensure it doesn't exceed the actual flash
+ *                          memory size.
+ */
+void flashpage_write_raw(void *target_addr, void *data, size_t len);
+
+/**
  * @brief   Read the given page into the given memory location
  *
  * @param[in]  page     page to read
- * @param[out] data     memory to write the page to, MUST be @p FLASHPAGE_SIZE
+ * @param[out] data     memory to write the page to, MUST be FLASHPAGE_SIZE
  *                      byte
  */
 void flashpage_read(int page, void *data);
@@ -119,7 +168,7 @@
  * @brief   Verify the given page against the given data
  *
  * @param[in] page      page to verify
- * @param[in] data      data to compare page against, MUST be @p FLASHPAGE_SIZE
+ * @param[in] data      data to compare page against, MUST be FLASHPAGE_SIZE
  *                      byte of data
  *
  * @return              FLASHPAGE_OK if data in the page is identical to @p data
@@ -133,7 +182,7 @@
  * This is a convenience function wrapping flashpage_write and flashpage_verify.
  *
  * @param[in] page      page to write
- * @param[in] data      data to write to the page, MUST be @p FLASHPAGE_SIZE
+ * @param[in] data      data to write to the page, MUST be FLASHPAGE_SIZE
  *                      byte.
  *
  * @return              FLASHPAGE_OK on success


[media] az6007: CodingStyle fixes

[media] az6007: CodingStyle fixes

Signed-off-by: Mauro Carvalho Chehab <ad86ba2154032c9f55743a190faa2459a9d61d42@redhat.com>

--- drivers/media/dvb/dvb-usb/az6007.c
+++ drivers/media/dvb/dvb-usb/az6007.c
@@ -211,9 +211,7 @@
 	if ((st->data[3] ^ st->data[4]) == 0xff)
 		code = code << 8 | st->data[3];
 	else
-		code = code << 16 | st->data[3] << 8| st->data[4];
-
-	printk("remote query key: %04x\n", code);
+		code = code << 16 | st->data[3] << 8 | st->data[4];

 	rc_keydown(d->rc_dev, code, st->data[5]);

@@ -302,11 +300,11 @@
 		ret = az6007_write(d, FX2_SCON1, 0, 3, NULL, 0);
 		if (ret < 0)
 			return ret;
-		msleep (150);
+		msleep(150);
 		ret = az6007_write(d, FX2_SCON1, 1, 3, NULL, 0);
 		if (ret < 0)
 			return ret;
-		msleep (430);
+		msleep(430);
 		ret = az6007_write(d, AZ6007_POWER, 0, 0, NULL, 0);
 		if (ret < 0)
 			return ret;
@@ -362,8 +360,8 @@
 			value = addr | (1 << 8);
 			length = 6 + msgs[i + 1].len;
 			len = msgs[i + 1].len;
-			ret = __az6007_read(d->udev, req, value, index, st->data,
-					       length);
+			ret = __az6007_read(d->udev, req, value, index,
+					    st->data, length);
 			if (ret >= len) {
 				for (j = 0; j < len; j++) {
 					msgs[i + 1].buf[j] = st->data[j + 5];
@@ -391,10 +389,11 @@
 			for (j = 0; j < len; j++) {
 				st->data[j] = msgs[i].buf[j + 1];
 				if (dvb_usb_az6007_debug & 2)
-					printk(KERN_CONT "0x%02x ", st->data[j]);
+					printk(KERN_CONT "0x%02x ",
+					       st->data[j]);
 			}
-			ret =  __az6007_write(d->udev, req, value, index, st->data,
-						 length);
+			ret =  __az6007_write(d->udev, req, value, index,
+					      st->data, length);
 		} else {
 			/* read bytes */
 			if (dvb_usb_az6007_debug & 2)
@@ -406,8 +405,8 @@
 			value = addr;
 			length = msgs[i].len + 6;
 			len = msgs[i].len;
-			ret = __az6007_read(d->udev, req, value, index, st->data,
-					       length);
+			ret = __az6007_read(d->udev, req, value, index,
+					    st->data, length);
 			for (j = 0; j < len; j++) {
 				msgs[i].buf[j] = st->data[j + 5];
 				if (dvb_usb_az6007_debug & 2)
@@ -466,7 +465,7 @@
 		__az6007_write(udev, 0x00, 0, 0, NULL, 0);
 	}

-	deb_info("Device is on %s state\n", *cold? "warm" : "cold");
+	deb_info("Device is on %s state\n", *cold ? "warm" : "cold");
 	return 0;
 }

@@ -514,7 +513,7 @@
 					}
 				}
 			},
-		}}
+		} }
 	} },
 	.power_ctrl       = az6007_power_ctrl,
 	.read_mac_address = az6007_read_mac_addr,


[media] az6007: Change the az6007 read/write routine parameter

Use usb_device for those routines, as it allows using them on
all places. While there, rename to better express the meaning.

Signed-off-by: Mauro Carvalho Chehab <ad86ba2154032c9f55743a190faa2459a9d61d42@redhat.com>

--- drivers/media/dvb/dvb-usb/az6007.c
+++ drivers/media/dvb/dvb-usb/az6007.c
@@ -96,13 +96,13 @@
 };

 /* check for mutex FIXME */
-static int az6007_usb_in_op(struct dvb_usb_device *d, u8 req, u16 value,
+static int az6007_read(struct usb_device *udev, u8 req, u16 value,
 			    u16 index, u8 *b, int blen)
 {
 	int ret = -1;

-	ret = usb_control_msg(d->udev,
-			      usb_rcvctrlpipe(d->udev, 0),
+	ret = usb_control_msg(udev,
+			      usb_rcvctrlpipe(udev, 0),
 			      req,
 			      USB_TYPE_VENDOR | USB_DIR_IN,
 			      value, index, b, blen, 5000);
@@ -119,7 +119,7 @@
 	return ret;
 }

-static int az6007_usb_out_op(struct dvb_usb_device *d, u8 req, u16 value,
+static int az6007_write(struct usb_device *udev, u8 req, u16 value,
 			     u16 index, u8 *b, int blen)
 {
 	int ret;
@@ -134,8 +134,8 @@
 		return -EOPNOTSUPP;
 	}

-	ret = usb_control_msg(d->udev,
-			      usb_sndctrlpipe(d->udev, 0),
+	ret = usb_control_msg(udev,
+			      usb_sndctrlpipe(udev, 0),
 			      req,
 			      USB_TYPE_VENDOR | USB_DIR_OUT,
 			      value, index, b, blen, 5000);
@@ -168,7 +168,7 @@

 	/* remove the following return to enabled remote querying */

-	az6007_usb_in_op(d, READ_REMOTE_REQ, 0, 0, key, 10);
+	az6007_read(d->udev, READ_REMOTE_REQ, 0, 0, key, 10);

 	deb_rc("remote query key: %x %d\n", key[1], key[1]);

@@ -191,13 +191,13 @@
 int az6007_power_ctrl(struct dvb_usb_device *d, int onoff)
 {
 	u8 v = onoff;
-	return az6007_usb_out_op(d,0xBC,v,3,NULL,1);
+	return az6007_write(d->udev,0xBC,v,3,NULL,1);
 }
 */

 static int az6007_read_mac_addr(struct dvb_usb_device *d, u8 mac[6])
 {
-	az6007_usb_in_op(d, 0xb7, 6, 0, &mac[0], 6);
+	az6007_read(d->udev, 0xb7, 6, 0, &mac[0], 6);
 	return 0;
 }

@@ -212,19 +212,19 @@
 	deb_info("az6007_frontend_poweron adap=%p adap->dev=%p\n",
 		 adap, adap->dev);

-	az6007_usb_out_op(d, AZ6007_POWER /* 0xbc */, 0, 2, NULL, 0);
+	az6007_write(d->udev, AZ6007_POWER /* 0xbc */, 0, 2, NULL, 0);
 	msleep(150);
-	az6007_usb_out_op(d, AZ6007_POWER /* 0xbc */, 1, 4, NULL, 0);
+	az6007_write(d->udev, AZ6007_POWER /* 0xbc */, 1, 4, NULL, 0);
 	msleep(100);
-	az6007_usb_out_op(d, AZ6007_POWER /* 0xbc */, 1, 3, NULL, 0);
+	az6007_write(d->udev, AZ6007_POWER /* 0xbc */, 1, 3, NULL, 0);
 	msleep(100);
-	az6007_usb_out_op(d, AZ6007_POWER /* 0xbc */, 1, 4, NULL, 0);
+	az6007_write(d->udev, AZ6007_POWER /* 0xbc */, 1, 4, NULL, 0);
 	msleep(100);
-	az6007_usb_out_op(d, FX2_SCON1 /* 0xc0 */, 0, 3, NULL, 0);
+	az6007_write(d->udev, FX2_SCON1 /* 0xc0 */, 0, 3, NULL, 0);
 	msleep (10);
-	az6007_usb_out_op(d, FX2_SCON1 /* 0xc0 */, 1, 3, NULL, 0);
+	az6007_write(d->udev, FX2_SCON1 /* 0xc0 */, 1, 3, NULL, 0);
 	msleep (10);
-	az6007_usb_out_op(d, AZ6007_POWER /* 0xbc */, 0, 0, NULL, 0);
+	az6007_write(d->udev, AZ6007_POWER /* 0xbc */, 0, 0, NULL, 0);

 	deb_info("az6007_frontend_poweron: OK\n");

@@ -246,7 +246,7 @@
 	value = 1;		/* high */
 	index = 3;
 	blen = 0;
-	ret = az6007_usb_out_op(adap->dev, req, value, index, NULL, blen);
+	ret = az6007_write(adap->dev->udev, req, value, index, NULL, blen);
 	if (ret != 0) {
 		err("az6007_frontend_reset failed 1 !!!");
 		return -EIO;
@@ -257,7 +257,7 @@
 	index = 3;
 	blen = 0;
 	msleep_interruptible(200);
-	ret = az6007_usb_out_op(adap->dev, req, value, index, NULL, blen);
+	ret = az6007_write(adap->dev->udev, req, value, index, NULL, blen);
 	if (ret != 0) {
 		err("az6007_frontend_reset failed 2 !!!");
 		return -EIO;
@@ -268,7 +268,7 @@
 	index = 3;
 	blen = 0;

-	ret = az6007_usb_out_op(adap->dev, req, value, index, NULL, blen);
+	ret = az6007_write(adap->dev->udev, req, value, index, NULL, blen);
 	if (ret != 0) {
 		err("az6007_frontend_reset failed 3 !!!");
 		return -EIO;
@@ -377,15 +377,15 @@

 	info("Sending poweron sequence");

-	az6007_usb_out_op(d, AZ6007_TS_THROUGH /* 0xc7 */, 0, 0, NULL, 0);
+	az6007_write(d->udev, AZ6007_TS_THROUGH /* 0xc7 */, 0, 0, NULL, 0);

 #if 0
 	// Seems to be a poweroff sequence
-	az6007_usb_out_op(d, 0xbc, 1, 3, NULL, 0);
-	az6007_usb_out_op(d, 0xbc, 1, 4, NULL, 0);
-	az6007_usb_out_op(d, 0xc0, 0, 3, NULL, 0);
-	az6007_usb_out_op(d, 0xc0, 1, 3, NULL, 0);
-	az6007_usb_out_op(d, 0xbc, 0, 1, NULL, 0);
+	az6007_write(d->udev, 0xbc, 1, 3, NULL, 0);
+	az6007_write(d->udev, 0xbc, 1, 4, NULL, 0);
+	az6007_write(d->udev, 0xc0, 0, 3, NULL, 0);
+	az6007_write(d->udev, 0xc0, 1, 3, NULL, 0);
+	az6007_write(d->udev, 0xbc, 0, 1, NULL, 0);
 #endif
 	return 0;
 }
@@ -434,7 +434,7 @@
 			value = addr | (1 << 8);
 			length = 6 + msgs[i + 1].len;
 			len = msgs[i + 1].len;
-			ret = az6007_usb_in_op(d, req, value, index, data,
+			ret = az6007_read(d->udev, req, value, index, data,
 					       length);
 			if (ret >= len) {
 				for (j = 0; j < len; j++) {
@@ -465,7 +465,7 @@
 				if (dvb_usb_az6007_debug & 2)
 					printk(KERN_CONT "0x%02x ", data[j]);
 			}
-			ret =  az6007_usb_out_op(d, req, value, index, data,
+			ret =  az6007_write(d->udev, req, value, index, data,
 						 length);
 		} else {
 			/* read bytes */
@@ -478,7 +478,7 @@
 			value = addr;
 			length = msgs[i].len + 6;
 			len = msgs[i].len;
-			ret = az6007_usb_in_op(d, req, value, index, data,
+			ret = az6007_read(d->udev, req, value, index, data,
 					       length);
 			for (j = 0; j < len; j++) {
 				msgs[i].buf[j] = data[j + 5];


[media] gspca - sonixj: Update the JPEG quality for best image transfer

During image capture, the filling rate of the isoc packets is computed.
It is then used by a work queue to update the current JPEG quality.

Tested-by: Franck Bourdonnec <b4df09091767bc6dc14f8f6c2873688bd05602b1@chez.com>
Signed-off-by: Jean-François Moine <e5394ce9c4b9ae7d2c4686830c5ac5f3b9028b6a@free.fr>
Signed-off-by: Mauro Carvalho Chehab <ad86ba2154032c9f55743a190faa2459a9d61d42@redhat.com>

--- drivers/media/video/gspca/sonixj.c
+++ drivers/media/video/gspca/sonixj.c
@@ -57,12 +57,18 @@
 	atomic_t avg_lum;
 	u32 exposure;

+	struct work_struct work;
+	struct workqueue_struct *work_thread;
+
+	u32 pktsz;			/* (used by pkt_scan) */
+	u16 npkt;
+	u8 nchg;
 	s8 short_mark;

 	u8 quality;			/* image quality */
-#define QUALITY_MIN 60
-#define QUALITY_MAX 95
-#define QUALITY_DEF 80
+#define QUALITY_MIN 25
+#define QUALITY_MAX 90
+#define QUALITY_DEF 70

 	u8 reg01;
 	u8 reg17;
@@ -99,6 +105,8 @@
 	SENSOR_SOI768,
 	SENSOR_SP80708,
 };
+
+static void qual_upd(struct work_struct *work);

 /* device flags */
 #define F_PDN_INV	0x01	/* inverse pin S_PWR_DN / sn_xxx tables */
@@ -1786,6 +1794,8 @@
 	sd->ag_cnt = -1;
 	sd->quality = QUALITY_DEF;

+	INIT_WORK(&sd->work, qual_upd);
+
 	return 0;
 }

@@ -2295,6 +2305,19 @@

 	sd->reg18 ^= 0x40;
 	reg_w1(gspca_dev, 0x18, sd->reg18);
+}
+
+/* JPEG quality update */
+/* This function is executed from a work queue. */
+static void qual_upd(struct work_struct *work)
+{
+	struct sd *sd = container_of(work, struct sd, work);
+	struct gspca_dev *gspca_dev = &sd->gspca_dev;
+
+	mutex_lock(&gspca_dev->usb_lock);
+	PDEBUG(D_STREAM, "qual_upd %d%%", sd->quality);
+	setjpegqual(gspca_dev);
+	mutex_unlock(&gspca_dev->usb_lock);
 }

 /* -- start the camera -- */
@@ -2610,6 +2633,11 @@
 	setcolors(gspca_dev);
 	setautogain(gspca_dev);
 	setfreq(gspca_dev);
+
+	sd->pktsz = sd->npkt = 0;
+	sd->nchg = sd->short_mark = 0;
+	sd->work_thread = create_singlethread_workqueue(MODULE_NAME);
+
 	return gspca_dev->usb_err;
 }

@@ -2684,6 +2712,20 @@
 	reg_w1(gspca_dev, 0x01, reg01);
 	/* Don't disable sensor clock as that disables the button on the cam */
 	/* reg_w1(gspca_dev, 0xf1, 0x01); */
+}
+
+/* called on streamoff with alt==0 and on disconnect */
+/* the usb_lock is held at entry - restore on exit */
+static void sd_stop0(struct gspca_dev *gspca_dev)
+{
+	struct sd *sd = (struct sd *) gspca_dev;
+
+	if (sd->work_thread != NULL) {
+		mutex_unlock(&gspca_dev->usb_lock);
+		destroy_workqueue(sd->work_thread);
+		mutex_lock(&gspca_dev->usb_lock);
+		sd->work_thread = NULL;
+	}
 }

 static void do_autogain(struct gspca_dev *gspca_dev)
@@ -2778,7 +2820,7 @@
 			int len)			/* iso packet length */
 {
 	struct sd *sd = (struct sd *) gspca_dev;
-	int i;
+	int i, new_qual;

 	/*
 	 * A frame ends on the marker
@@ -2818,6 +2860,10 @@
 		data += i;
 	}

+	/* count the packets and their size */
+	sd->npkt++;
+	sd->pktsz += len;
+
 	/* search backwards if there is a marker in the packet */
 	for (i = len - 1; --i >= 0; ) {
 		if (data[i] != 0xff) {
@@ -2843,19 +2889,53 @@
 	return;

 	/* marker found */
-	/* if some error, discard the frame */
+	/* if some error, discard the frame and decrease the quality */
 marker_found:
+	new_qual = 0;
 	if (i > 2) {
 		if (data[i - 2] != 0xff || data[i - 1] != 0xd9) {
 			gspca_dev->last_packet_type = DISCARD_PACKET;
+			new_qual = -3;
 		}
 	} else if (i + 6 < len) {
 		if (data[i + 6] & 0x08) {
 			gspca_dev->last_packet_type = DISCARD_PACKET;
+			new_qual = -5;
 		}
 	}

 	gspca_frame_add(gspca_dev, LAST_PACKET, data, i);
+
+	/* compute the filling rate and a new JPEG quality */
+	if (new_qual == 0) {
+		int r;
+
+		r = (sd->pktsz * 100) /
+			(sd->npkt *
+				gspca_dev->urb[0]->iso_frame_desc[0].length);
+		if (r >= 85)
+			new_qual = -3;
+		else if (r < 75)
+			new_qual = 2;
+	}
+	if (new_qual != 0) {
+		sd->nchg += new_qual;
+		if (sd->nchg < -6 || sd->nchg >= 12) {
+			sd->nchg = 0;
+			new_qual += sd->quality;
+			if (new_qual < QUALITY_MIN)
+				new_qual = QUALITY_MIN;
+			else if (new_qual > QUALITY_MAX)
+				new_qual = QUALITY_MAX;
+			if (new_qual != sd->quality) {
+				sd->quality = new_qual;
+				queue_work(sd->work_thread, &sd->work);
+			}
+		}
+	} else {
+		sd->nchg = 0;
+	}
+	sd->pktsz = sd->npkt = 0;

 	/* if the marker is smaller than 62 bytes,
 	 * memorize the number of bytes to skip in the next packet */
@@ -2863,7 +2943,6 @@
 		sd->short_mark = i + 62 - len;
 		return;
 	}
-
 	if (sd->ag_cnt >= 0)
 		set_lum(sd, data + i);

@@ -2876,22 +2955,6 @@
 				sd->jpeg_hdr, JPEG_HDR_SZ);
 		gspca_frame_add(gspca_dev, INTER_PACKET, data, len);
 	}
-}
-
-static int sd_set_jcomp(struct gspca_dev *gspca_dev,
-			struct v4l2_jpegcompression *jcomp)
-{
-	struct sd *sd = (struct sd *) gspca_dev;
-
-	if (jcomp->quality < QUALITY_MIN)
-		sd->quality = QUALITY_MIN;
-	else if (jcomp->quality > QUALITY_MAX)
-		sd->quality = QUALITY_MAX;
-	else
-		sd->quality = jcomp->quality;
-	if (gspca_dev->streaming)
-		setjpegqual(gspca_dev);
-	return 0;
 }

 static int sd_get_jcomp(struct gspca_dev *gspca_dev,
@@ -2955,10 +3018,10 @@
 	.init = sd_init,
 	.start = sd_start,
 	.stopN = sd_stopN,
+	.stop0 = sd_stop0,
 	.pkt_scan = sd_pkt_scan,
 	.dq_callback = do_autogain,
 	.get_jcomp = sd_get_jcomp,
-	.set_jcomp = sd_set_jcomp,
 	.querymenu = sd_querymenu,
 #if defined(CONFIG_INPUT) || defined(CONFIG_INPUT_MODULE)
 	.int_pkt_scan = sd_int_pkt_scan,


V4L/DVB (13894): gspca - sonixj: Add more controls.

- sharpness
- brightness for adcm1700
- adjust brightness/exposure for adcm1700
- add some comments

Signed-off-by: Jean-Francois Moine <e5394ce9c4b9ae7d2c4686830c5ac5f3b9028b6a@free.fr>
Signed-off-by: Mauro Carvalho Chehab <ad86ba2154032c9f55743a190faa2459a9d61d42@redhat.com>

--- drivers/media/video/gspca/sonixj.c
+++ drivers/media/video/gspca/sonixj.c
@@ -45,6 +45,7 @@
 	u8 red;
 	u8 gamma;
 	u8 vflip;			/* ov7630/ov7648 only */
+	u8 sharpness;
 	u8 infrared;			/* mt9v111 only */
 	u8 freq;			/* ov76xx only */
 	u8 quality;			/* image quality */
@@ -97,6 +98,8 @@
 static int sd_getautogain(struct gspca_dev *gspca_dev, __s32 *val);
 static int sd_setvflip(struct gspca_dev *gspca_dev, __s32 val);
 static int sd_getvflip(struct gspca_dev *gspca_dev, __s32 *val);
+static int sd_setsharpness(struct gspca_dev *gspca_dev, __s32 val);
+static int sd_getsharpness(struct gspca_dev *gspca_dev, __s32 *val);
 static int sd_setinfrared(struct gspca_dev *gspca_dev, __s32 val);
 static int sd_getinfrared(struct gspca_dev *gspca_dev, __s32 *val);
 static int sd_setfreq(struct gspca_dev *gspca_dev, __s32 val);
@@ -226,8 +229,23 @@
 	    .set = sd_setvflip,
 	    .get = sd_getvflip,
 	},
+#define SHARPNESS_IDX 8
+	{
+	    {
+		.id	 = V4L2_CID_SHARPNESS,
+		.type    = V4L2_CTRL_TYPE_INTEGER,
+		.name    = "Sharpness",
+		.minimum = 0,
+		.maximum = 255,
+		.step    = 1,
+#define SHARPNESS_DEF 90
+		.default_value = SHARPNESS_DEF,
+	    },
+	    .set = sd_setsharpness,
+	    .get = sd_getsharpness,
+	},
 /* mt9v111 only */
-#define INFRARED_IDX 8
+#define INFRARED_IDX 9
 	{
 	    {
 		.id      = V4L2_CID_INFRARED,
@@ -243,7 +261,7 @@
 	    .get = sd_getinfrared,
 	},
 /* ov7630/ov7648/ov7660 only */
-#define FREQ_IDX 9
+#define FREQ_IDX 10
 	{
 	    {
 		.id	 = V4L2_CID_POWER_LINE_FREQUENCY,
@@ -263,7 +281,7 @@
 /* table of the disabled controls */
 static __u32 ctrl_dis[] = {
 	(1 << INFRARED_IDX) | (1 << VFLIP_IDX) | (1 << FREQ_IDX) |
-	(1 << AUTOGAIN_IDX) | (1 << BRIGHTNESS_IDX), /* SENSOR_ADCM1700 0 */
+			(1 << AUTOGAIN_IDX),	/* SENSOR_ADCM1700 0 */
 	(1 << INFRARED_IDX) | (1 << VFLIP_IDX) | (1 << FREQ_IDX),
 						/* SENSOR_HV7131R 1 */
 	(1 << INFRARED_IDX) | (1 << VFLIP_IDX) | (1 << FREQ_IDX),
@@ -314,7 +332,7 @@

 static const u8 sn_adcm1700[0x1c] = {
 /*	reg0	reg1	reg2	reg3	reg4	reg5	reg6	reg7 */
-	0x00,	0x42,	0x60,	0x00,	0x1a,	0x20,	0x20,	0x20,
+	0x00,	0x43,	0x60,	0x00,	0x1a,	0x00,	0x00,	0x00,
 /*	reg8	reg9	rega	regb	regc	regd	rege	regf */
 	0x80,	0x51,	0x00,	0x00,	0x00,	0x00,	0x00,	0x00,
 /*	reg10	reg11	reg12	reg13	reg14	reg15	reg16	reg17 */
@@ -479,7 +497,7 @@
 };
 static const u8 adcm1700_sensor_init[][8] = {
 	{0xa0, 0x51, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x10},
-	{0xb0, 0x51, 0x04, 0x08, 0x00, 0x00, 0x00, 0x10},
+	{0xb0, 0x51, 0x04, 0x08, 0x00, 0x00, 0x00, 0x10},	/* reset */
 	{0xdd, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
 	{0xb0, 0x51, 0x04, 0x00, 0x00, 0x00, 0x00, 0x10},
 	{0xdd, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
@@ -498,15 +516,19 @@
 	{}
 };
 static const u8 adcm1700_sensor_param1[][8] = {
-	{0xb0, 0x51, 0x26, 0xf9, 0x01, 0x00, 0x00, 0x10},
+	{0xb0, 0x51, 0x26, 0xf9, 0x01, 0x00, 0x00, 0x10},	/* exposure? */
 	{0xd0, 0x51, 0x1e, 0x8e, 0x8e, 0x8e, 0x8e, 0x10},

 	{0xa0, 0x51, 0xfe, 0x01, 0x00, 0x00, 0x00, 0x10},
 	{0xb0, 0x51, 0x00, 0x02, 0x00, 0x00, 0x00, 0x10},
 	{0xa0, 0x51, 0xfe, 0x10, 0x00, 0x00, 0x00, 0x10},
 	{0xb0, 0x51, 0x32, 0x00, 0x72, 0x00, 0x00, 0x10},
-	{0xd0, 0x51, 0x1e, 0x8e, 0x91, 0x91, 0x8e, 0x10},
-
+	{0xd0, 0x51, 0x1e, 0xbe, 0xd7, 0xe8, 0xbe, 0x10},	/* exposure? */
+
+	{0xa0, 0x51, 0xfe, 0x01, 0x00, 0x00, 0x00, 0x10},
+	{0xb0, 0x51, 0x00, 0x02, 0x00, 0x00, 0x00, 0x10},
+	{0xa0, 0x51, 0xfe, 0x10, 0x00, 0x00, 0x00, 0x10},
+	{0xb0, 0x51, 0x32, 0x00, 0xa2, 0x00, 0x00, 0x10},
 	{}
 };
 static const u8 hv7131r_sensor_init[][8] = {
@@ -1347,7 +1369,7 @@

 	switch (sd->sensor) {
 	case SENSOR_ADCM1700:
-		reg_w1(gspca_dev, 0x01, 0x42);
+		reg_w1(gspca_dev, 0x01, 0x43);
 		reg_w1(gspca_dev, 0x17, 0x62);
 		reg_w1(gspca_dev, 0x01, 0x42);
 		reg_w1(gspca_dev, 0x01, 0x42);
@@ -1447,6 +1469,14 @@
 	sd->autogain = AUTOGAIN_DEF;
 	sd->ag_cnt = -1;
 	sd->vflip = VFLIP_DEF;
+	switch (sd->sensor) {
+	case SENSOR_OM6802:
+		sd->sharpness = 0x10;
+		break;
+	default:
+		sd->sharpness = SHARPNESS_DEF;
+		break;
+	}
 	sd->infrared = INFRARED_DEF;
 	sd->freq = FREQ_DEF;
 	sd->quality = QUALITY_DEF;
@@ -1617,7 +1647,9 @@
 	k2 = ((int) sd->brightness - 0x8000) >> 10;
 	switch (sd->sensor) {
 	case SENSOR_ADCM1700:
-		return;
+		if (k2 > 0x1f)
+			k2 = 0;		/* only positive Y offset */
+		break;
 	case SENSOR_HV7131R:
 		expo = sd->brightness << 4;
 		if (expo > 0x002dc6c0)
@@ -1765,6 +1797,11 @@
 			comn |= 0x80;
 	}
 	i2c_w1(&sd->gspca_dev, 0x75, comn);
+}
+
+static void setsharpness(struct sd *sd)
+{
+	reg_w1(&sd->gspca_dev, 0x99, sd->sharpness);
 }

 static void setinfrared(struct sd *sd)
@@ -1926,20 +1963,20 @@
 	reg_w1(gspca_dev, 0x13, sn9c1xx[0x13]);
 	reg_w1(gspca_dev, 0x18, sn9c1xx[0x18]);
 	if (sd->sensor == SENSOR_ADCM1700) {
-		reg_w1(gspca_dev, 0xd2, 0x3a);		/* DC29 */
-		reg_w1(gspca_dev, 0xd3, 0x30);
+		reg_w1(gspca_dev, 0xd2, 0x3a);	/* AE_H_SIZE = 116 */
+		reg_w1(gspca_dev, 0xd3, 0x30);	/* AE_V_SIZE = 96 */
 	} else {
-		reg_w1(gspca_dev, 0xd2, 0x6a);		/* DC29 */
-		reg_w1(gspca_dev, 0xd3, 0x50);
+		reg_w1(gspca_dev, 0xd2, 0x6a);	/* AE_H_SIZE = 212 */
+		reg_w1(gspca_dev, 0xd3, 0x50);	/* AE_V_SIZE = 160 */
 	}
 	reg_w1(gspca_dev, 0xc6, 0x00);
 	reg_w1(gspca_dev, 0xc7, 0x00);
 	if (sd->sensor == SENSOR_ADCM1700) {
-		reg_w1(gspca_dev, 0xc8, 0x2c);
-		reg_w1(gspca_dev, 0xc9, 0x24);
+		reg_w1(gspca_dev, 0xc8, 0x2c);	/* AW_H_STOP = 352 */
+		reg_w1(gspca_dev, 0xc9, 0x24);	/* AW_V_STOP = 288 */
 	} else {
-		reg_w1(gspca_dev, 0xc8, 0x50);
-		reg_w1(gspca_dev, 0xc9, 0x3c);
+		reg_w1(gspca_dev, 0xc8, 0x50);	/* AW_H_STOP = 640 */
+		reg_w1(gspca_dev, 0xc9, 0x3c);	/* AW_V_STOP = 480 */
 	}
 	reg_w1(gspca_dev, 0x18, sn9c1xx[0x18]);
 	switch (sd->sensor) {
@@ -1964,48 +2001,39 @@
 		break;
 	}
 	reg_w1(gspca_dev, 0x17, reg17);
-/* set reg1 was here */
-	reg_w1(gspca_dev, 0x05, sn9c1xx[5]);	/* red */
-	reg_w1(gspca_dev, 0x07, sn9c1xx[7]);	/* green */
-	reg_w1(gspca_dev, 0x06, sn9c1xx[6]);	/* blue */
+
+	reg_w1(gspca_dev, 0x05, 0x00);		/* red */
+	reg_w1(gspca_dev, 0x07, 0x00);		/* green */
+	reg_w1(gspca_dev, 0x06, 0x00);		/* blue */
 	reg_w1(gspca_dev, 0x14, sn9c1xx[0x14]);

 	setgamma(gspca_dev);

+/*fixme: 8 times with all zeroes and 1 or 2 times with normal values */
 	for (i = 0; i < 8; i++)
 		reg_w(gspca_dev, 0x84, reg84, sizeof reg84);
 	switch (sd->sensor) {
 	case SENSOR_ADCM1700:
-		reg_w1(gspca_dev, 0x9a, 0x05);
-		reg_w1(gspca_dev, 0x99, 0x60);
-		break;
-	case SENSOR_MT9V111:
-		reg_w1(gspca_dev, 0x9a, 0x07);
-		reg_w1(gspca_dev, 0x99, 0x59);
-		break;
-	case SENSOR_OM6802:
-		reg_w1(gspca_dev, 0x9a, 0x08);
-		reg_w1(gspca_dev, 0x99, 0x10);
-		break;
-	case SENSOR_OV7648:
-		reg_w1(gspca_dev, 0x9a, 0x0a);
-		reg_w1(gspca_dev, 0x99, 0x60);
-		break;
 	case SENSOR_OV7660:
 	case SENSOR_SP80708:
 		reg_w1(gspca_dev, 0x9a, 0x05);
-		reg_w1(gspca_dev, 0x99, 0x59);
+		break;
+	case SENSOR_MT9V111:
+		reg_w1(gspca_dev, 0x9a, 0x07);
+		break;
+	case SENSOR_OV7648:
+		reg_w1(gspca_dev, 0x9a, 0x0a);
 		break;
 	default:
 		reg_w1(gspca_dev, 0x9a, 0x08);
-		reg_w1(gspca_dev, 0x99, 0x59);
-		break;
-	}
+		break;
+	}
+	setsharpness(sd);

 	reg_w(gspca_dev, 0x84, reg84, sizeof reg84);
-	reg_w1(gspca_dev, 0x05, sn9c1xx[5]);	/* red */
-	reg_w1(gspca_dev, 0x07, sn9c1xx[7]);	/* green */
-	reg_w1(gspca_dev, 0x06, sn9c1xx[6]);	/* blue */
+	reg_w1(gspca_dev, 0x05, 0x20);		/* red */
+	reg_w1(gspca_dev, 0x07, 0x20);		/* green */
+	reg_w1(gspca_dev, 0x06, 0x20);		/* blue */

 	init = NULL;
 	mode = gspca_dev->cam.cam_mode[gspca_dev->curr_mode].priv;
@@ -2392,6 +2420,24 @@
 	struct sd *sd = (struct sd *) gspca_dev;

 	*val = sd->autogain;
+	return 0;
+}
+
+static int sd_setsharpness(struct gspca_dev *gspca_dev, __s32 val)
+{
+	struct sd *sd = (struct sd *) gspca_dev;
+
+	sd->sharpness = val;
+	if (gspca_dev->streaming)
+		setsharpness(sd);
+	return 0;
+}
+
+static int sd_getsharpness(struct gspca_dev *gspca_dev, __s32 *val)
+{
+	struct sd *sd = (struct sd *) gspca_dev;
+
+	*val = sd->sharpness;
 	return 0;
 }


[media] gspca - sonixj: Infrared bug fix and enhancement

The infrared was set by sensor write instead of bridge GPIO.
It is now settable by the standard control ILLUMINATOR_1.
A module parameter permits to set the right GPIO bit according
to the StarCam model.

Signed-off-by: Jean-François Moine <e5394ce9c4b9ae7d2c4686830c5ac5f3b9028b6a@free.fr>
Signed-off-by: Mauro Carvalho Chehab <ad86ba2154032c9f55743a190faa2459a9d61d42@redhat.com>

--- drivers/media/video/gspca/sonixj.c
+++ drivers/media/video/gspca/sonixj.c
@@ -25,11 +25,11 @@
 #include "gspca.h"
 #include "jpeg.h"

-#define V4L2_CID_INFRARED (V4L2_CID_PRIVATE_BASE + 0)
-
 MODULE_AUTHOR("Jean-François Moine <http://moinejf.free.fr>");
 MODULE_DESCRIPTION("GSPCA/SONIX JPEG USB Camera Driver");
 MODULE_LICENSE("GPL");
+
+static int starcam;

 /* controls */
 enum e_ctrl {
@@ -43,7 +43,7 @@
 	HFLIP,
 	VFLIP,
 	SHARPNESS,
-	INFRARED,
+	ILLUM,
 	FREQ,
 	NCTRLS		/* number of controls */
 };
@@ -100,7 +100,8 @@
 };

 /* device flags */
-#define PDN_INV	1		/* inverse pin S_PWR_DN / sn_xxx tables */
+#define F_PDN_INV	0x01	/* inverse pin S_PWR_DN / sn_xxx tables */
+#define F_ILLUM		0x02	/* presence of illuminator */

 /* sn9c1xx definitions */
 /* register 0x01 */
@@ -124,7 +125,7 @@
 static void setautogain(struct gspca_dev *gspca_dev);
 static void sethvflip(struct gspca_dev *gspca_dev);
 static void setsharpness(struct gspca_dev *gspca_dev);
-static void setinfrared(struct gspca_dev *gspca_dev);
+static void setillum(struct gspca_dev *gspca_dev);
 static void setfreq(struct gspca_dev *gspca_dev);

 static const struct ctrl sd_ctrls[NCTRLS] = {
@@ -251,18 +252,17 @@
 	    },
 	    .set_control = setsharpness
 	},
-/* mt9v111 only */
-[INFRARED] = {
+[ILLUM] = {
 	    {
-		.id      = V4L2_CID_INFRARED,
+		.id      = V4L2_CID_ILLUMINATORS_1,
 		.type    = V4L2_CTRL_TYPE_BOOLEAN,
-		.name    = "Infrared",
+		.name    = "Illuminator / infrared",
 		.minimum = 0,
 		.maximum = 1,
 		.step    = 1,
 		.default_value = 0,
 	    },
-	    .set_control = setinfrared
+	    .set_control = setillum
 	},
 /* ov7630/ov7648/ov7660 only */
 [FREQ] = {
@@ -282,73 +282,59 @@
 /* table of the disabled controls */
 static const __u32 ctrl_dis[] = {
 [SENSOR_ADCM1700] =	(1 << AUTOGAIN) |
-			(1 << INFRARED) |
 			(1 << HFLIP) |
 			(1 << VFLIP) |
 			(1 << FREQ),

-[SENSOR_GC0307] =	(1 << INFRARED) |
+[SENSOR_GC0307] =	(1 << HFLIP) |
+			(1 << VFLIP) |
+			(1 << FREQ),
+
+[SENSOR_HV7131R] =	(1 << HFLIP) |
+			(1 << FREQ),
+
+[SENSOR_MI0360] =	(1 << HFLIP) |
+			(1 << VFLIP) |
+			(1 << FREQ),
+
+[SENSOR_MI0360B] =	(1 << HFLIP) |
+			(1 << VFLIP) |
+			(1 << FREQ),
+
+[SENSOR_MO4000] =	(1 << HFLIP) |
+			(1 << VFLIP) |
+			(1 << FREQ),
+
+[SENSOR_MT9V111] =	(1 << HFLIP) |
+			(1 << VFLIP) |
+			(1 << FREQ),
+
+[SENSOR_OM6802] =	(1 << HFLIP) |
+			(1 << VFLIP) |
+			(1 << FREQ),
+
+[SENSOR_OV7630] =	(1 << HFLIP),
+
+[SENSOR_OV7648] =	(1 << HFLIP),
+
+[SENSOR_OV7660] =	(1 << AUTOGAIN) |
+			(1 << HFLIP) |
+			(1 << VFLIP),
+
+[SENSOR_PO1030] =	(1 << AUTOGAIN) |
 			(1 << HFLIP) |
 			(1 << VFLIP) |
 			(1 << FREQ),

-[SENSOR_HV7131R] =	(1 << INFRARED) |
-			(1 << HFLIP) |
+[SENSOR_PO2030N] =	(1 << AUTOGAIN) |
 			(1 << FREQ),

-[SENSOR_MI0360] =	(1 << INFRARED) |
+[SENSOR_SOI768] =	(1 << AUTOGAIN) |
 			(1 << HFLIP) |
 			(1 << VFLIP) |
 			(1 << FREQ),

-[SENSOR_MI0360B] =	(1 << INFRARED) |
-			(1 << HFLIP) |
-			(1 << VFLIP) |
-			(1 << FREQ),
-
-[SENSOR_MO4000] =	(1 << INFRARED) |
-			(1 << HFLIP) |
-			(1 << VFLIP) |
-			(1 << FREQ),
-
-[SENSOR_MT9V111] =	(1 << HFLIP) |
-			(1 << VFLIP) |
-			(1 << FREQ),
-
-[SENSOR_OM6802] =	(1 << INFRARED) |
-			(1 << HFLIP) |
-			(1 << VFLIP) |
-			(1 << FREQ),
-
-[SENSOR_OV7630] =	(1 << INFRARED) |
-			(1 << HFLIP),
-
-[SENSOR_OV7648] =	(1 << INFRARED) |
-			(1 << HFLIP),
-
-[SENSOR_OV7660] =	(1 << AUTOGAIN) |
-			(1 << INFRARED) |
-			(1 << HFLIP) |
-			(1 << VFLIP),
-
-[SENSOR_PO1030] =	(1 << AUTOGAIN) |
-			(1 << INFRARED) |
-			(1 << HFLIP) |
-			(1 << VFLIP) |
-			(1 << FREQ),
-
-[SENSOR_PO2030N] =	(1 << AUTOGAIN) |
-			(1 << INFRARED) |
-			(1 << FREQ),
-
-[SENSOR_SOI768] =	(1 << AUTOGAIN) |
-			(1 << INFRARED) |
-			(1 << HFLIP) |
-			(1 << VFLIP) |
-			(1 << FREQ),
-
 [SENSOR_SP80708] =	(1 << AUTOGAIN) |
-			(1 << INFRARED) |
 			(1 << HFLIP) |
 			(1 << VFLIP) |
 			(1 << FREQ),
@@ -1876,6 +1862,8 @@
 	sd->i2c_addr = sn9c1xx[9];

 	gspca_dev->ctrl_dis = ctrl_dis[sd->sensor];
+	if (!(sd->flags & F_ILLUM))
+		gspca_dev->ctrl_dis |= (1 << ILLUM);

 	return gspca_dev->usb_err;
 }
@@ -2199,16 +2187,20 @@
 	reg_w1(gspca_dev, 0x99, sd->ctrls[SHARPNESS].val);
 }

-static void setinfrared(struct gspca_dev *gspca_dev)
+static void setillum(struct gspca_dev *gspca_dev)
 {
 	struct sd *sd = (struct sd *) gspca_dev;

-	if (gspca_dev->ctrl_dis & (1 << INFRARED))
+	if (gspca_dev->ctrl_dis & (1 << ILLUM))
 		return;
-/*fixme: different sequence for StarCam Clip and StarCam 370i */
-/* Clip */
-	i2c_w1(gspca_dev, 0x02,				/* gpio */
-		sd->ctrls[INFRARED].val ? 0x66 : 0x64);
+	if (starcam)
+		reg_w1(gspca_dev, 0x02,			/* gpio */
+			sd->ctrls[ILLUM].val ?
+					0x55 : 0x54);	/* 370i */
+	else
+		reg_w1(gspca_dev, 0x02,
+			sd->ctrls[ILLUM].val ?
+					0x66 : 0x64);	/* Clip */
 }

 static void setfreq(struct gspca_dev *gspca_dev)
@@ -2346,7 +2338,7 @@
 	/* sensor clock already enabled in sd_init */
 	/* reg_w1(gspca_dev, 0xf1, 0x00); */
 	reg01 = sn9c1xx[1];
-	if (sd->flags & PDN_INV)
+	if (sd->flags & F_PDN_INV)
 		reg01 ^= S_PDN_INV;		/* power down inverted */
 	reg_w1(gspca_dev, 0x01, reg01);

@@ -2912,8 +2904,8 @@
 static const struct usb_device_id device_table[] = {
 	{USB_DEVICE(0x0458, 0x7025), BS(SN9C120, MI0360)},
 	{USB_DEVICE(0x0458, 0x702e), BS(SN9C120, OV7660)},
-	{USB_DEVICE(0x045e, 0x00f5), BSF(SN9C105, OV7660, PDN_INV)},
-	{USB_DEVICE(0x045e, 0x00f7), BSF(SN9C105, OV7660, PDN_INV)},
+	{USB_DEVICE(0x045e, 0x00f5), BSF(SN9C105, OV7660, F_PDN_INV)},
+	{USB_DEVICE(0x045e, 0x00f7), BSF(SN9C105, OV7660, F_PDN_INV)},
 	{USB_DEVICE(0x0471, 0x0327), BS(SN9C105, MI0360)},
 	{USB_DEVICE(0x0471, 0x0328), BS(SN9C105, MI0360)},
 	{USB_DEVICE(0x0471, 0x0330), BS(SN9C105, MI0360)},
@@ -2925,7 +2917,7 @@
 /*	{USB_DEVICE(0x0c45, 0x607b), BS(SN9C102P, OV7660)}, */
 	{USB_DEVICE(0x0c45, 0x607c), BS(SN9C102P, HV7131R)},
 /*	{USB_DEVICE(0x0c45, 0x607e), BS(SN9C102P, OV7630)}, */
-	{USB_DEVICE(0x0c45, 0x60c0), BS(SN9C105, MI0360)},
+	{USB_DEVICE(0x0c45, 0x60c0), BSF(SN9C105, MI0360, F_ILLUM)},
 						/* or MT9V111 */
 /*	{USB_DEVICE(0x0c45, 0x60c2), BS(SN9C105, P1030xC)}, */
 /*	{USB_DEVICE(0x0c45, 0x60c8), BS(SN9C105, OM6802)}, */
@@ -3004,3 +2996,7 @@

 module_init(sd_mod_init);
 module_exit(sd_mod_exit);
+
+module_param(starcam, int, 0644);
+MODULE_PARM_DESC(starcam,
+	"StarCam model. 0: Clip, 1: 370i");


V4L/DVB (6647): xc2028: retry firmware load if tuner does not respond

In practice, the tuner occasionally fails to respond correctly after a
firmware load.  Retry the firmware load if the firmware/hardware version
we read back from the tuner after programming does not match what we
expect.

Signed-off-by: Chris Pascoe <e388f5e7da7561c354d5dee07ec667900799a1b2@itee.uq.edu.au>
Signed-off-by: Mauro Carvalho Chehab <ad86ba2154032c9f55743a190faa2459a9d61d42@infradead.org>

--- drivers/media/video/tuner-xc2028.c
+++ drivers/media/video/tuner-xc2028.c
@@ -74,6 +74,9 @@
 	struct firmware_description *firm;
 	int			firm_size;
 	__u16			firm_version;
+
+	__u16			hwmodel;
+	__u16			hwvers;

 	struct xc2028_ctrl	ctrl;

@@ -607,7 +610,7 @@
 			  v4l2_std_id std, fe_bandwidth_t bandwidth)
 {
 	struct xc2028_data      *priv = fe->tuner_priv;
-	int			rc = 0;
+	int			rc = 0, is_retry = 0;
 	unsigned int		type = 0;
 	struct firmware_properties new_fw;
 	u16			version, hwmodel;
@@ -654,6 +657,7 @@
 		};
 	}

+retry:
 	new_fw.type = type;
 	new_fw.id = std;
 	new_fw.std_req = std;
@@ -739,13 +743,33 @@
 			&new_fw.id, new_fw.scode_nr);

 check_device:
-	xc2028_get_reg(priv, 0x0004, &version);
-	xc2028_get_reg(priv, 0x0008, &hwmodel);
+	if (xc2028_get_reg(priv, 0x0004, &version) < 0 ||
+	    xc2028_get_reg(priv, 0x0008, &hwmodel) < 0) {
+		tuner_err("Unable to read tuner registers.\n");
+		goto fail;
+	}

 	tuner_info("Device is Xceive %d version %d.%d, "
 		   "firmware version %d.%d\n",
 		   hwmodel, (version & 0xf000) >> 12, (version & 0xf00) >> 8,
 		   (version & 0xf0) >> 4, version & 0xf);
+
+	/* Check firmware version against what we downloaded. */
+	if (priv->firm_version != ((version & 0xf0) << 4 | (version & 0x0f))) {
+		tuner_err("Incorrect readback of firmware version.\n");
+		goto fail;
+	}
+
+	/* Check that the tuner hardware model remains consistent over time. */
+	if (priv->hwmodel == 0 && (hwmodel == 2028 || hwmodel == 3028)) {
+		priv->hwmodel = hwmodel;
+		priv->hwvers  = version & 0xff00;
+	} else if (priv->hwmodel == 0 || priv->hwmodel != hwmodel ||
+		   priv->hwvers != (version & 0xff00)) {
+		tuner_err("Read invalid device hardware information - tuner "
+			  "hung?\n");
+		goto fail;
+	}

 	memcpy(&priv->cur_fw, &new_fw, sizeof(priv->cur_fw));

@@ -761,6 +785,13 @@

 fail:
 	memset(&priv->cur_fw, 0, sizeof(priv->cur_fw));
+	if (!is_retry) {
+		msleep(50);
+		is_retry = 1;
+		tuner_dbg("Retrying firmware load\n");
+		goto retry;
+	}
+
 	if (rc == -ENOENT)
 		rc = -EINVAL;
 	return rc;


mmc: sdhci-esdhc-imx: remove emulation of uhs_mode

We no longer need to emulate the uhs_mode field of the host control2
register - the main sdhci driver never reads this back to evaluate
the current mode as it caches the current mode instead.

Signed-off-by: Russell King <f6aa0246ff943bfa8602cdf60d40c481b38ed232@arm.linux.org.uk>
Tested-by: Markus Pargmann <b9e0f7aed71fa470d5913fb2df2da788a8fb0eb2@pengutronix.de>
Tested-by: Stephen Warren <5ef2a23ba3aff51d1cfc8c113c1ec34b608b3b13@nvidia.com>
Signed-off-by: Ulf Hansson <fe47b31f388f85ce6ddf64bf3a0cf6b46077d0e6@linaro.org>
Signed-off-by: Chris Ball <711c73f64afdce07b7e38039a96d2224209e9a6c@printf.net>

--- drivers/mmc/host/sdhci-esdhc-imx.c
+++ drivers/mmc/host/sdhci-esdhc-imx.c
@@ -160,7 +160,6 @@
 		MULTIBLK_IN_PROCESS, /* exact multiblock cmd in process */
 		WAIT_FOR_INT,        /* sent CMD12, waiting for response INT */
 	} multiblock_status;
-	u32 uhs_mode;
 	u32 is_ddr;
 };

@@ -382,7 +381,6 @@
 		if (val & ESDHC_MIX_CTRL_SMPCLK_SEL)
 			ret |= SDHCI_CTRL_TUNED_CLK;

-		ret |= (imx_data->uhs_mode & SDHCI_CTRL_UHS_MASK);
 		ret &= ~SDHCI_CTRL_PRESET_VAL_ENABLE;

 		return ret;
@@ -429,7 +427,6 @@
 		else
 			new_val &= ~ESDHC_VENDOR_SPEC_VSELECT;
 		writel(new_val, host->ioaddr + ESDHC_VENDOR_SPEC);
-		imx_data->uhs_mode = val & SDHCI_CTRL_UHS_MASK;
 		if (imx_data->socdata->flags & ESDHC_FLAG_MAN_TUNING) {
 			new_val = readl(host->ioaddr + ESDHC_MIX_CTRL);
 			if (val & SDHCI_CTRL_TUNED_CLK)
@@ -841,28 +838,20 @@
 	return pinctrl_select_state(imx_data->pinctrl, pinctrl);
 }

-static void esdhc_set_uhs_signaling(struct sdhci_host *host, unsigned int uhs)
+static void esdhc_set_uhs_signaling(struct sdhci_host *host, unsigned timing)
 {
 	struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
 	struct pltfm_imx_data *imx_data = pltfm_host->priv;
 	struct esdhc_platform_data *boarddata = &imx_data->boarddata;

-	switch (uhs) {
+	switch (timing) {
 	case MMC_TIMING_UHS_SDR12:
-		imx_data->uhs_mode = SDHCI_CTRL_UHS_SDR12;
-		break;
 	case MMC_TIMING_UHS_SDR25:
-		imx_data->uhs_mode = SDHCI_CTRL_UHS_SDR25;
-		break;
 	case MMC_TIMING_UHS_SDR50:
-		imx_data->uhs_mode = SDHCI_CTRL_UHS_SDR50;
-		break;
 	case MMC_TIMING_UHS_SDR104:
 	case MMC_TIMING_MMC_HS200:
-		imx_data->uhs_mode = SDHCI_CTRL_UHS_SDR104;
 		break;
 	case MMC_TIMING_UHS_DDR50:
-		imx_data->uhs_mode = SDHCI_CTRL_UHS_DDR50;
 		writel(readl(host->ioaddr + ESDHC_MIX_CTRL) |
 				ESDHC_MIX_CTRL_DDREN,
 				host->ioaddr + ESDHC_MIX_CTRL);
@@ -879,7 +868,7 @@
 		break;
 	}

-	esdhc_change_pinstate(host, uhs);
+	esdhc_change_pinstate(host, timing);
 }

 static void esdhc_reset(struct sdhci_host *host, u8 mask)


tile: fix panic bug in napi support for tilegx network driver

The code used to call napi_disable() in an interrupt handler
(from smp_call_function), which in turn could call msleep().
Unfortunately you can't sleep in an interrupt context.

Luckily it turns out all the NAPI support functions are
just operating on data structures and not on any deeply
per-cpu data, so we can arrange to set up and tear down all
the NAPI state on the core driving the process, and just
do the IRQ enable/disable as a smp_call_function thing.

Signed-off-by: Chris Metcalf <074881f6f5da4d3b5278870ff234d1077ee622c0@tilera.com>
Signed-off-by: David S. Miller <fe08d3c717adf2ae63592e4c9aec6e3e404d8e3e@davemloft.net>

--- drivers/net/ethernet/tile/tilegx.c
+++ drivers/net/ethernet/tile/tilegx.c
@@ -650,37 +650,13 @@
 	return HRTIMER_NORESTART;
 }

-/* Helper function for "tile_net_update()".
- * "dev" (i.e. arg) is the device being brought up or down,
- * or NULL if all devices are now down.
- */
-static void tile_net_update_cpu(void *arg)
-{
-	struct tile_net_info *info = &__get_cpu_var(per_cpu_info);
-	struct net_device *dev = arg;
-
-	if (!info->has_iqueue)
-		return;
-
-	if (dev != NULL) {
-		if (!info->napi_added) {
-			netif_napi_add(dev, &info->napi,
-				       tile_net_poll, TILE_NET_WEIGHT);
-			info->napi_added = true;
-		}
-		if (!info->napi_enabled) {
-			napi_enable(&info->napi);
-			info->napi_enabled = true;
-		}
+/* Helper function for "tile_net_update()". */
+static void manage_ingress_irq(void *enable)
+{
+	if (enable)
 		enable_percpu_irq(ingress_irq, 0);
-	} else {
+	else
 		disable_percpu_irq(ingress_irq);
-		if (info->napi_enabled) {
-			napi_disable(&info->napi);
-			info->napi_enabled = false;
-		}
-		/* FIXME: Drain the iqueue. */
-	}
 }

 /* Helper function for tile_net_open() and tile_net_stop().
@@ -717,10 +693,35 @@
 		return -EIO;
 	}

-	/* Update all cpus, sequentially (to protect "netif_napi_add()"). */
-	for_each_online_cpu(cpu)
-		smp_call_function_single(cpu, tile_net_update_cpu,
-					 (saw_channel ? dev : NULL), 1);
+	/* Update all cpus, sequentially (to protect "netif_napi_add()").
+	 * We use on_each_cpu to handle the IPI mask or unmask.
+	 */
+	if (!saw_channel)
+		on_each_cpu(manage_ingress_irq, (void *)0, 1);
+	for_each_online_cpu(cpu) {
+		struct tile_net_info *info = &per_cpu(per_cpu_info, cpu);
+		if (!info->has_iqueue)
+			continue;
+		if (saw_channel) {
+			if (!info->napi_added) {
+				netif_napi_add(dev, &info->napi,
+					       tile_net_poll, TILE_NET_WEIGHT);
+				info->napi_added = true;
+			}
+			if (!info->napi_enabled) {
+				napi_enable(&info->napi);
+				info->napi_enabled = true;
+			}
+		} else {
+			if (info->napi_enabled) {
+				napi_disable(&info->napi);
+				info->napi_enabled = false;
+			}
+			/* FIXME: Drain the iqueue. */
+		}
+	}
+	if (saw_channel)
+		on_each_cpu(manage_ingress_irq, (void *)1, 1);

 	/* HACK: Allow packets to flow in the simulator. */
 	if (saw_channel)


Compiler warning fix.

Compiler warning fix.

--- src/lib-storage/index/index-mail.c
+++ src/lib-storage/index/index-mail.c
@@ -822,8 +822,8 @@
 			/* EPIPE = input already closed. allow the caller to
 			   decide if that is an error or not. */
 			i_assert(!success ||
-				 i_stream_read(parser_input) == -1 &&
-				 !i_stream_have_bytes_left(parser_input));
+				 (i_stream_read(parser_input) == -1 &&
+				  !i_stream_have_bytes_left(parser_input)));
 		} else {
 			errno = parser_input->stream_errno;
 			mail_storage_set_critical(mail->mail.mail.box->storage,


net/virtio: unmap port IO for legacy device

For legacy devices, we should also unmap the port IO
resource on device removal.

Fixes: b8f04520ad71 ("virtio: use PCI ioport API")
Cc: stable@dpdk.org

Signed-off-by: Tiwei Bie <f338cf29d7d69ff1bc99f755ebfb0eb0accd409e@intel.com>
Reviewed-by: Maxime Coquelin <9a2667dee3b90866bbc9c2696cff2b7d5616c95a@redhat.com>

--- drivers/net/virtio/virtio_ethdev.c
+++ drivers/net/virtio/virtio_ethdev.c
@@ -1876,6 +1876,8 @@
 static int
 eth_virtio_dev_uninit(struct rte_eth_dev *eth_dev)
 {
+	struct virtio_hw *hw = eth_dev->data->dev_private;
+
 	PMD_INIT_FUNC_TRACE();

 	if (rte_eal_process_type() == RTE_PROC_SECONDARY)
@@ -1888,8 +1890,11 @@
 	eth_dev->tx_pkt_burst = NULL;
 	eth_dev->rx_pkt_burst = NULL;

-	if (eth_dev->device)
+	if (eth_dev->device) {
 		rte_pci_unmap_device(RTE_ETH_DEV_TO_PCI(eth_dev));
+		if (!hw->modern)
+			rte_pci_ioport_unmap(VTPCI_IO(hw));
+	}

 	PMD_INIT_LOG(DEBUG, "dev_uninit completed");


Index arguments are signed

Index arguments are signed

--- autowiring/AutoNetServer.h
+++ autowiring/AutoNetServer.h
@@ -60,7 +60,7 @@

 private:
   // Extract arguments from list of strings, parse and pass to handler
-  template<typename Fx, typename... Args, size_t... N>
+  template<typename Fx, typename... Args, int... N>
   void AddEventHandler(const std::string& event, Fx&& handler, void (Fx::*pfn)(Args...) const, index_tuple<N...>) {
     AddEventHandlerInternal(
       event,


fix map update bug. :)

fix map update bug. :)

git-svn-id: 24a995eca3b83137dd7eab3408044d7832e202f7@58656 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33

--- src/lib/canvas/evas_object_image.c
+++ src/lib/canvas/evas_object_image.c
@@ -2700,67 +2700,68 @@
 	     evas_object_render_pre_prev_cur_add(&e->clip_changes, obj);
 	     if (!o->pixel_updates) goto done;
 	  }
-	if ((o->cur.border.l == 0) &&
-	    (o->cur.border.r == 0) &&
-	    (o->cur.border.t == 0) &&
-	    (o->cur.border.b == 0) &&
-            (o->cur.image.w > 0) &&
-            (o->cur.image.h > 0))
-	  {
-	     Eina_Rectangle *rr;
-
-	     EINA_LIST_FREE(o->pixel_updates, rr)
-	       {
-		  Evas_Coord idw, idh, idx, idy;
-		  int x, y, w, h;
-
-		  e->engine.func->image_dirty_region(e->engine.data.output, o->engine_data, rr->x, rr->y, rr->w, rr->h);
-
-		  idx = evas_object_image_figure_x_fill(obj, o->cur.fill.x, o->cur.fill.w, &idw);
-		  idy = evas_object_image_figure_y_fill(obj, o->cur.fill.y, o->cur.fill.h, &idh);
-
-		  if (idw < 1) idw = 1;
-		  if (idh < 1) idh = 1;
-		  if (idx > 0) idx -= idw;
-		  if (idy > 0) idy -= idh;
-		  while (idx < obj->cur.geometry.w)
-		    {
-		       Evas_Coord ydy;
-
-		       ydy = idy;
-		       x = idx;
-		       w = ((int)(idx + idw)) - x;
-		       while (idy < obj->cur.geometry.h)
-			 {
-			    Eina_Rectangle r;
-
-			    y = idy;
-			    h = ((int)(idy + idh)) - y;
-
-			    r.x = ((rr->x - 1) * w) / o->cur.image.w;
-			    r.y = ((rr->y - 1) * h) / o->cur.image.h;
-			    r.w = ((rr->w + 2) * w) / o->cur.image.w;
-			    r.h = ((rr->h + 2) * h) / o->cur.image.h;
-			    r.x += obj->cur.geometry.x + x;
-			    r.y += obj->cur.geometry.y + y;
-			    evas_add_rect(&e->clip_changes, r.x, r.y, r.w, r.h);
-			    idy += h;
-			 }
-		       idx += idw;
-		       idy = ydy;
-		    }
-		  eina_rectangle_free(rr);
-	       }
-	     goto done;
-	  }
-	else
-	  {
-	     if (o->pixel_updates)
-	       {
+        if (o->pixel_updates)
+          {
+             if ((o->cur.border.l == 0) &&
+                 (o->cur.border.r == 0) &&
+                 (o->cur.border.t == 0) &&
+                 (o->cur.border.b == 0) &&
+                 (o->cur.image.w > 0) &&
+                 (o->cur.image.h > 0) &&
+                (!((obj->cur.map) && (obj->cur.usemap))))
+               {
+                  Eina_Rectangle *rr;
+
+                  EINA_LIST_FREE(o->pixel_updates, rr)
+                    {
+                       Evas_Coord idw, idh, idx, idy;
+                       int x, y, w, h;
+
+                       e->engine.func->image_dirty_region(e->engine.data.output, o->engine_data, rr->x, rr->y, rr->w, rr->h);
+
+                       idx = evas_object_image_figure_x_fill(obj, o->cur.fill.x, o->cur.fill.w, &idw);
+                       idy = evas_object_image_figure_y_fill(obj, o->cur.fill.y, o->cur.fill.h, &idh);
+
+                       if (idw < 1) idw = 1;
+                       if (idh < 1) idh = 1;
+                       if (idx > 0) idx -= idw;
+                       if (idy > 0) idy -= idh;
+                       while (idx < obj->cur.geometry.w)
+                         {
+                            Evas_Coord ydy;
+
+                            ydy = idy;
+                            x = idx;
+                            w = ((int)(idx + idw)) - x;
+                            while (idy < obj->cur.geometry.h)
+                              {
+                                 Eina_Rectangle r;
+
+                                 y = idy;
+                                 h = ((int)(idy + idh)) - y;
+
+                                 r.x = ((rr->x - 1) * w) / o->cur.image.w;
+                                 r.y = ((rr->y - 1) * h) / o->cur.image.h;
+                                 r.w = ((rr->w + 2) * w) / o->cur.image.w;
+                                 r.h = ((rr->h + 2) * h) / o->cur.image.h;
+                                 r.x += obj->cur.geometry.x + x;
+                                 r.y += obj->cur.geometry.y + y;
+                                 evas_add_rect(&e->clip_changes, r.x, r.y, r.w, r.h);
+                                 idy += h;
+                              }
+                            idx += idw;
+                            idy = ydy;
+                         }
+                       eina_rectangle_free(rr);
+                    }
+                  goto done;
+               }
+             else
+               {
 		  Eina_Rectangle *r;
-
+
 		  EINA_LIST_FREE(o->pixel_updates, r)
-		    eina_rectangle_free(r);
+                     eina_rectangle_free(r);
 		  e->engine.func->image_dirty_region(e->engine.data.output, o->engine_data, 0, 0, o->cur.image.w, o->cur.image.h);
 		  evas_object_render_pre_prev_cur_add(&e->clip_changes, obj);
 		  goto done;