Index: m5602_s5k83a.c
===================================================================
--- m5602_s5k83a.c	(revision 404)
+++ m5602_s5k83a.c	(working copy)
@@ -184,21 +184,33 @@
 	case V4L2_CID_BRIGHTNESS:
 		err = s5k83a_get_brightness(cam, &reg_data);
 		ctrl->value = reg_data;
-		PDEBUG(DBG_V4L2_CID, "get brightness 0x%x", ctrl->value);
+		PDEBUG(DBG_V4L2_CID, "Get brightness 0x%x", ctrl->value);
 		break;
 
 	case V4L2_CID_WHITENESS:
 		err = s5k83a_get_whiteness(cam, &reg_data);
 		ctrl->value = reg_data;
-		PDEBUG(DBG_V4L2_CID, "get whiteness 0x%x", ctrl->value);
+		PDEBUG(DBG_V4L2_CID, "Get whiteness 0x%x", ctrl->value);
 		break;
 
 	case V4L2_CID_GAIN:
 		err = s5k83a_get_gain(cam, &reg_data);
 		ctrl->value = reg_data;
-		PDEBUG(DBG_V4L2_CID, "get gain 0x%x", ctrl->value);
+		PDEBUG(DBG_V4L2_CID, "Get gain 0x%x", ctrl->value);
 		break;
-
+		
+	case V4L2_CID_HFLIP:
+		err = s5k83a_get_hflip(cam, &reg_data);
+		ctrl->value = reg_data;
+		PDEBUG(DBG_V4L2_CID, "Get hflip 0x%x", ctrl->value);
+		break;		
+	
+	case V4L2_CID_VFLIP:
+		err = s5k83a_get_vflip(cam, &reg_data);
+		ctrl->value = reg_data;
+		PDEBUG(DBG_V4L2_CID, "Get vflip 0x%x", ctrl->value);
+		break;		
+		
 	default:
 		PDEBUG(DBG_V4L2_CID, "Unknown V4L2 CID 0x%x", ctrl->id);
 		err = -EINVAL;
@@ -227,6 +239,16 @@
 		PDEBUG(DBG_V4L2_CID, "Set gain to 0x%x", ctrl->value);
 		break;
 
+	case V4L2_CID_HFLIP:
+		err = s5k83a_set_hflip(cam, ctrl->value);
+		PDEBUG(DBG_V4L2_CID, "Set hflip 0x%x", ctrl->value);
+		break;		
+
+	case V4L2_CID_VFLIP:
+		err = s5k83a_set_vflip(cam, ctrl->value);
+		PDEBUG(DBG_V4L2_CID, "Set vflip 0x%x", ctrl->value);
+		break;		
+	
 	default:
 		PDEBUG(DBG_V4L2_CID,
 		       "Illegal V4L2 CID %d, value %d", ctrl->id, ctrl->value);
@@ -363,3 +385,84 @@
 
 	return (err < 0) ? err : 0;
 }
+
+int s5k83a_set_hflip(struct m5602_camera *cam, u8 value){
+	int err = 0;
+	u8 data[1];
+
+	data[0] = 0x05;
+	err = s5k83a_write_sensor(cam, S5K83A_PAGE_MAP, data, 1);
+	if (err < 0)
+		return err;
+
+	err = s5k83a_read_sensor(cam, S5K83A_FLIP, data, 1);
+	if (err < 0)
+		return err;
+	
+	/* set or zero seven bit, six bit is vflip */
+	data[0] = (value)? (data[0] & 0x40) | 0x80 | S5K83A_FLIP_MASK: (data[0] & 0x40) | S5K83A_FLIP_MASK;
+	err = s5k83a_write_sensor(cam, S5K83A_FLIP, data, 1);
+	if (err < 0)
+		return err;
+	
+	data[0] = (value)? 0x0a : 0x0b;
+	err = s5k83a_write_sensor(cam, S5K83A_HFLIP_TUNE, data, 1);
+	
+	return (err < 0) ? err : 0;	
+}
+
+int s5k83a_get_hflip(struct m5602_camera *cam, u8 *reg_data){
+	int err = 0;
+	u8 data[1];
+
+	data[0] = 0x05;
+	err = s5k83a_write_sensor(cam, S5K83A_PAGE_MAP, data, 1);
+	if (err < 0)
+		return err;
+
+	err = s5k83a_read_sensor(cam, S5K83A_FLIP, data, 1);
+	*reg_data = (data[0] | 0x80)? 1 : 0;
+	
+	return (err < 0) ? err : 0;	
+}
+
+int s5k83a_set_vflip(struct m5602_camera *cam, u8 value){
+	int err = 0;
+	u8 data[1];
+
+	data[0] = 0x05;
+	err = s5k83a_write_sensor(cam, S5K83A_PAGE_MAP, data, 1);
+	if (err < 0)
+		return err;
+
+	err = s5k83a_read_sensor(cam, S5K83A_FLIP, data, 1);
+	if (err < 0)
+		return err;
+	
+	/* set or zero six bit, seven is hflip */
+	data[0] = (value)? (data[0] & 0x80) | 0x40 | S5K83A_FLIP_MASK: (data[0] & 0x80) | S5K83A_FLIP_MASK;
+	err = s5k83a_write_sensor(cam, S5K83A_FLIP, data, 1);
+	if (err < 0)
+		return err;
+	
+	data[0] = (value)? 0x0b : 0x0a;
+	err = s5k83a_write_sensor(cam, S5K83A_VFLIP_TUNE, data, 1);
+	
+	return (err < 0) ? err : 0;	
+}
+
+int s5k83a_get_vflip(struct m5602_camera *cam, u8 *reg_data){
+	int err = 0;
+	u8 data[1];
+
+	data[0] = 0x05;
+	err = s5k83a_write_sensor(cam, S5K83A_PAGE_MAP, data, 1);
+	if (err < 0)
+		return err;
+
+	err = s5k83a_read_sensor(cam, S5K83A_FLIP, data, 1);
+	*reg_data = (data[0] | 0x40)? 1 : 0;
+	
+	return (err < 0) ? err : 0;	
+}
+
Index: m5602_s5k83a.h
===================================================================
--- m5602_s5k83a.h	(revision 404)
+++ m5602_s5k83a.h	(working copy)
@@ -22,14 +22,18 @@
 #include "m5602_sensor.h"
 
 #define S5K83A_PAGE_MAP			0xec
-#define S5K83A_GAIN			0x18
+#define S5K83A_FLIP				0x01
+#define S5K83A_HFLIP_TUNE		0x03
+#define S5K83A_VFLIP_TUNE		0x05
+#define S5K83A_GAIN				0x18
 #define S5K83A_WHITENESS		0x0a
 #define S5K83A_BRIGHTNESS 		0x1b
 
 #define S5K83A_DEFAULT_BRIGHTNESS	0x71
 #define S5K83A_DEFAULT_WHITENESS	0x7e
-#define S5K83A_DEFAULT_GAIN		0x00
-#define S5K83A_MAXIMUM_GAIN		0x3c
+#define S5K83A_DEFAULT_GAIN			0x00
+#define S5K83A_MAXIMUM_GAIN			0x3c
+#define S5K83A_FLIP_MASK			0x10
 
 /*****************************************************************************/
 
@@ -59,6 +63,10 @@
 int s5k83a_get_whiteness(struct m5602_camera *cam, u8 *reg_data);
 int s5k83a_set_gain(struct m5602_camera *cam, u8 value);
 int s5k83a_get_gain(struct m5602_camera *cam, u8 *reg_data);
+int s5k83a_set_hflip(struct m5602_camera *cam, u8 value);
+int s5k83a_get_hflip(struct m5602_camera *cam, u8 *reg_data);
+int s5k83a_set_vflip(struct m5602_camera *cam, u8 value);
+int s5k83a_get_vflip(struct m5602_camera *cam, u8 *reg_data);
 
 static struct m5602_sensor s5k83a = {
 	.name = "S5K83A",
@@ -100,6 +108,24 @@
 			.step = 0x01,
 			.default_value = S5K83A_DEFAULT_GAIN,
 			.flags = V4L2_CTRL_FLAG_SLIDER
+		},
+		{
+			.id 		= V4L2_CID_HFLIP,
+			.type 		= V4L2_CTRL_TYPE_BOOLEAN,
+			.name 		= "horizontal flip",
+			.minimum 	= 0,
+			.maximum 	= 1,
+			.step 		= 1,
+			.default_value 	= 0
+		},
+		{
+			.id 		= V4L2_CID_VFLIP,
+			.type 		= V4L2_CTRL_TYPE_BOOLEAN,
+			.name 		= "vertical flip",
+			.minimum 	= 0,
+			.maximum 	= 1,
+			.step 		= 1,
+			.default_value 	= 0
 		}
 	},
 	.cropcap = {
@@ -175,15 +201,15 @@
 	{SENSOR, S5K83A_PAGE_MAP, 0x00, 0x00},
 	{SENSOR, 0x7b, 0xff, 0x00},
 	{SENSOR, S5K83A_PAGE_MAP, 0x05, 0x00},
-	{SENSOR, 0x01, 0x50, 0x00},
+	{SENSOR, S5K83A_FLIP, 0x50, 0x00},
 	{SENSOR, 0x12, 0x20, 0x00},
 	{SENSOR, 0x17, 0x40, 0x00},
 	{SENSOR, S5K83A_BRIGHTNESS, 0x0f, 0x00},
 	{SENSOR, 0x1c, 0x00, 0x00},
 	{SENSOR, 0x02, 0x70, 0x00},
-	{SENSOR, 0x03, 0x0b, 0x00},
+	{SENSOR, S5K83A_HFLIP_TUNE, 0x0b, 0x00},
 	{SENSOR, 0x04, 0xf0, 0x00},
-	{SENSOR, 0x05, 0x0b, 0x00},
+	{SENSOR, S5K83A_VFLIP_TUNE, 0x0b, 0x00},
 	{SENSOR, S5K83A_PAGE_MAP, 0x05, 0x00},
 
 	{BRIDGE, M5602_XB_SEN_CLK_DIV, 0x06, 0x00},
@@ -282,16 +308,16 @@
 	/* ff ( init value )is very dark) || 71 and f0 better */
 	{SENSOR, 0x7b, 0xff, 0x00},
 	{SENSOR, S5K83A_PAGE_MAP, 0x05, 0x00},
-	{SENSOR, 0x01, 0x50, 0x00},
+	{SENSOR, S5K83A_FLIP, 0x50, 0x00},
 	{SENSOR, 0x12, 0x20, 0x00},
 	{SENSOR, 0x17, 0x40, 0x00},
 	{SENSOR, S5K83A_BRIGHTNESS, 0x0f, 0x00},
 	{SENSOR, 0x1c, 0x00, 0x00},
 	{SENSOR, 0x02, 0x70, 0x00},
 	/* some values like 0x10 give a blue-purple image */
-	{SENSOR, 0x03, 0x0b, 0x00},
+	{SENSOR, S5K83A_HFLIP_TUNE, 0x0b, 0x00},
 	{SENSOR, 0x04, 0xf0, 0x00},
-	{SENSOR, 0x05, 0x0b, 0x00},
+	{SENSOR, S5K83A_VFLIP_TUNE, 0x0b, 0x00},
 	{SENSOR, S5K83A_PAGE_MAP, 0x05, 0x00},
 
 	{BRIDGE, M5602_XB_SEN_CLK_DIV, 0x06, 0x00},
@@ -370,15 +396,15 @@
 	{SENSOR, S5K83A_PAGE_MAP, 0x00, 0x00},
 	{SENSOR, 0x7b, 0xff, 0x00},
 	{SENSOR, S5K83A_PAGE_MAP, 0x05, 0x00},
-	{SENSOR, 0x01, 0x50, 0x00},
+	{SENSOR, S5K83A_FLIP, 0x50, 0x00},
 	{SENSOR, 0x12, 0x20, 0x00},
 	{SENSOR, 0x17, 0x40, 0x00},
 	{SENSOR, S5K83A_BRIGHTNESS, 0x0f, 0x00},
 	{SENSOR, 0x1c, 0x00, 0x00},
 	{SENSOR, 0x02, 0x70, 0x00},
-	{SENSOR, 0x03, 0x0b, 0x00},
+	{SENSOR, S5K83A_HFLIP_TUNE, 0x0b, 0x00},
 	{SENSOR, 0x04, 0xf0, 0x00},
-	{SENSOR, 0x05, 0x0b, 0x00},
+	{SENSOR, S5K83A_VFLIP_TUNE, 0x0b, 0x00},
 	{SENSOR, S5K83A_PAGE_MAP, 0x05, 0x00},
 
 	{BRIDGE, M5602_XB_SEN_CLK_DIV, 0x06, 0x00},
@@ -437,7 +463,14 @@
 	{SENSOR, S5K83A_WHITENESS, S5K83A_DEFAULT_WHITENESS, 0x00},
 
 	/* set default gain */
-	{SENSOR_LONG, 0x18, 0x00, S5K83A_DEFAULT_GAIN}
+	{SENSOR_LONG, 0x18, 0x00, S5K83A_DEFAULT_GAIN},
+	
+	/* set default flip */
+	{SENSOR, S5K83A_PAGE_MAP, 0x05, 0x00},
+	{SENSOR, S5K83A_FLIP, 0x00 | S5K83A_FLIP_MASK, 0x00},
+	{SENSOR, S5K83A_HFLIP_TUNE, 0x0b, 0x00},
+	{SENSOR, S5K83A_VFLIP_TUNE, 0x0a, 0x00}
+
 };
 
 #endif
