Skip to content
This repository has been archived by the owner on Feb 22, 2024. It is now read-only.

Commit

Permalink
#47. Adding sensor regs and defs for Ov5647 and IMX219. Not currently…
Browse files Browse the repository at this point in the history
… probing correctly.
  • Loading branch information
techyian committed Jan 31, 2020
1 parent 076cfbd commit 56bb0b0
Show file tree
Hide file tree
Showing 13 changed files with 2,291 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/MMALSharp/Config/BayerOrder.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@

namespace MMALSharp.Config
{
public enum BayerOrder
{
//Carefully ordered so that an hflip is ^1,
//and a vflip is ^2.
BAYER_ORDER_BGGR,
BAYER_ORDER_GBRG,
BAYER_ORDER_GRBG,
BAYER_ORDER_RGGB
}
}
150 changes: 150 additions & 0 deletions src/MMALSharp/Config/ModeDefs/Imx219ModeDefs.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,150 @@
using MMALSharp.Config.SensorRegs;
using System;
using System.Collections.Generic;
using System.Text;

namespace MMALSharp.Config.ModeDefs
{
public static class Imx219ModeDefs
{
public static readonly List<ModeDef> ModeDefs = new List<ModeDef>
{
new ModeDef
{
Regs = Imx219SensorRegs.Imx219Regs,
NumRegs = Imx219SensorRegs.Imx219Regs.Count,
Width = 3280,
Height = 2464,
Encoding = 0,
Order = BayerOrder.BAYER_ORDER_BGGR,
NativeBitDepth = 10,
ImageId = 0x2B,
DataLanes = 2,
MinVts = 2504,
LineTimeNs = 18904,
Timing = new int[] { 0, 0, 0, 0 },
Term = new int[] { 0, 0 },
BlackLevel = 66
},
new ModeDef
{
Regs = Imx219SensorRegs.Imx219Mode1Regs,
NumRegs = Imx219SensorRegs.Imx219Mode1Regs.Count,
Width = 1920,
Height = 1080,
Encoding = 0,
Order = BayerOrder.BAYER_ORDER_BGGR,
NativeBitDepth = 10,
ImageId = 0x2B,
DataLanes = 2,
MinVts = 1084,
LineTimeNs = 18904,
Timing = new int[] { 0, 0, 0, 0 },
Term = new int[] { 0, 0 },
BlackLevel = 66
},
new ModeDef
{
Regs = Imx219SensorRegs.Imx219Mode2Regs,
NumRegs = Imx219SensorRegs.Imx219Mode2Regs.Count,
Width = 3280,
Height = 2464,
Encoding = 0,
Order = BayerOrder.BAYER_ORDER_BGGR,
NativeBitDepth = 10,
ImageId = 0x2B,
DataLanes = 2,
MinVts = 2468,
LineTimeNs = 18904,
Timing = new int[] { 0, 0, 0, 0 },
Term = new int[] { 0, 0 },
BlackLevel = 66
},
new ModeDef
{
Regs = Imx219SensorRegs.Imx219Mode3Regs,
NumRegs = Imx219SensorRegs.Imx219Mode3Regs.Count,
Width = 3280,
Height = 2464,
Encoding = 0,
Order = BayerOrder.BAYER_ORDER_BGGR,
NativeBitDepth = 10,
ImageId = 0x2B,
DataLanes = 2,
MinVts = 2468,
LineTimeNs = 18904,
Timing = new int[] { 0, 0, 0, 0 },
Term = new int[] { 0, 0 },
BlackLevel = 66
},
new ModeDef
{
Regs = Imx219SensorRegs.Imx219Mode4Regs,
NumRegs = Imx219SensorRegs.Imx219Mode4Regs.Count,
Width = 1640,
Height = 1232,
Encoding = 0,
Order = BayerOrder.BAYER_ORDER_BGGR,
NativeBitDepth = 10,
ImageId = 0x2B,
DataLanes = 2,
MinVts = 1236,
LineTimeNs = 18904,
Timing = new int[] { 0, 0, 0, 0 },
Term = new int[] { 0, 0 },
BlackLevel = 66
},
new ModeDef
{
Regs = Imx219SensorRegs.Imx219Mode5Regs,
NumRegs = Imx219SensorRegs.Imx219Mode5Regs.Count,
Width = 1640,
Height = 922,
Encoding = 0,
Order = BayerOrder.BAYER_ORDER_BGGR,
NativeBitDepth = 10,
ImageId = 0x2B,
DataLanes = 2,
MinVts = 926,
LineTimeNs = 18904,
Timing = new int[] { 0, 0, 0, 0 },
Term = new int[] { 0, 0 },
BlackLevel = 66
},
new ModeDef
{
Regs = Imx219SensorRegs.Imx219Mode6Regs,
NumRegs = Imx219SensorRegs.Imx219Mode6Regs.Count,
Width = 1280,
Height = 720,
Encoding = 0,
Order = BayerOrder.BAYER_ORDER_BGGR,
NativeBitDepth = 10,
ImageId = 0x2B,
DataLanes = 2,
MinVts = 724,
LineTimeNs = 19517,
Timing = new int[] { 0, 0, 0, 0 },
Term = new int[] { 0, 0 },
BlackLevel = 66
},
new ModeDef
{
Regs = Imx219SensorRegs.Imx219Mode7Regs,
NumRegs = Imx219SensorRegs.Imx219Mode7Regs.Count,
Width = 640,
Height = 480,
Encoding = 0,
Order = BayerOrder.BAYER_ORDER_BGGR,
NativeBitDepth = 10,
ImageId = 0x2B,
DataLanes = 2,
MinVts = 484,
LineTimeNs = 19517,
Timing = new int[] { 0, 0, 0, 0 },
Term = new int[] { 0, 0 },
BlackLevel = 66
}
};
}
}
23 changes: 23 additions & 0 deletions src/MMALSharp/Config/ModeDefs/ModeDef.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
using MMALSharp.Config.SensorRegs;
using System.Collections.Generic;

namespace MMALSharp.Config
{
public class ModeDef
{
public List<SensorReg> Regs { get; set; }
public int NumRegs { get; set; }
public int Width { get; set; }
public int Height { get; set; }
public int Encoding { get; set; }
public BayerOrder Order { get; set; }
public int NativeBitDepth { get; set; }
public int ImageId { get; set; }
public int DataLanes { get; set; }
public int MinVts { get; set; }
public int LineTimeNs { get; set; }
public int[] Timing { get; set; }
public int[] Term { get; set; }
public int BlackLevel { get; set; }
}
}
148 changes: 148 additions & 0 deletions src/MMALSharp/Config/ModeDefs/Ov5647ModeDefs.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,148 @@
using MMALSharp.Config.SensorRegs;
using System.Collections.Generic;

namespace MMALSharp.Config.ModeDefs
{
public static class Ov5647ModeDefs
{
public static readonly List<ModeDef> ModeDefs = new List<ModeDef>
{
new ModeDef
{
Regs = Ov5647SensorRegs.Ov5647Regs,
NumRegs = Ov5647SensorRegs.Ov5647Regs.Count,
Width = 2592,
Height = 1944,
Encoding = 0,
Order = BayerOrder.BAYER_ORDER_GBRG,
NativeBitDepth = 10,
ImageId = 0x2B,
DataLanes = 2,
MinVts = 1968,
LineTimeNs = 32503,
Timing = new int[] { 0, 0, 0, 0 },
Term = new int[] { 0, 0 },
BlackLevel = 16
},
new ModeDef
{
Regs = Ov5647SensorRegs.Ov5647Mode1Regs,
NumRegs = Ov5647SensorRegs.Ov5647Mode1Regs.Count,
Width = 1920,
Height = 1080,
Encoding = 0,
Order = BayerOrder.BAYER_ORDER_GBRG,
NativeBitDepth = 10,
ImageId = 0x2B,
DataLanes = 2,
MinVts = 1104,
LineTimeNs = 29584,
Timing = new int[] { 0, 0, 0, 0 },
Term = new int[] { 0, 0 },
BlackLevel = 16
},
new ModeDef
{
Regs = Ov5647SensorRegs.Ov5647Mode2Regs,
NumRegs = Ov5647SensorRegs.Ov5647Mode2Regs.Count,
Width = 2592,
Height = 1944,
Encoding = 0,
Order = BayerOrder.BAYER_ORDER_GBRG,
NativeBitDepth = 10,
ImageId = 0x2B,
DataLanes = 2,
MinVts = 1968,
LineTimeNs = 32503,
Timing = new int[] { 0, 0, 0, 0 },
Term = new int[] { 0, 0 },
BlackLevel = 16
},
new ModeDef
{
Regs = Ov5647SensorRegs.Ov5647Mode3Regs,
NumRegs = Ov5647SensorRegs.Ov5647Mode3Regs.Count,
Width = 2592,
Height = 1944,
Encoding = 0,
Order = BayerOrder.BAYER_ORDER_GBRG,
NativeBitDepth = 10,
ImageId = 0x2B,
DataLanes = 2,
MinVts = 1968,
LineTimeNs = 183789,
Timing = new int[] { 0, 0, 0, 0 },
Term = new int[] { 0, 0 },
BlackLevel = 16
},
new ModeDef
{
Regs = Ov5647SensorRegs.Ov5647Mode4Regs,
NumRegs = Ov5647SensorRegs.Ov5647Mode4Regs.Count,
Width = 1296,
Height = 976,
Encoding = 0,
Order = BayerOrder.BAYER_ORDER_GBRG,
NativeBitDepth = 10,
ImageId = 0x2B,
DataLanes = 2,
MinVts = 996,
LineTimeNs = 23216,
Timing = new int[] { 0, 0, 0, 0 },
Term = new int[] { 0, 0 },
BlackLevel = 16
},
new ModeDef
{
Regs = Ov5647SensorRegs.Ov5647Mode5Regs,
NumRegs = Ov5647SensorRegs.Ov5647Mode5Regs.Count,
Width = 1296,
Height = 730,
Encoding = 0,
Order = BayerOrder.BAYER_ORDER_GBRG,
NativeBitDepth = 10,
ImageId = 0x2B,
DataLanes = 2,
MinVts = 754,
LineTimeNs = 23216,
Timing = new int[] { 0, 0, 0, 0 },
Term = new int[] { 0, 0 },
BlackLevel = 16
},
new ModeDef
{
Regs = Ov5647SensorRegs.Ov5647Mode6Regs,
NumRegs = Ov5647SensorRegs.Ov5647Mode6Regs.Count,
Width = 640,
Height = 480,
Encoding = 0,
Order = BayerOrder.BAYER_ORDER_GBRG,
NativeBitDepth = 10,
ImageId = 0x2B,
DataLanes = 2,
MinVts = 484,
LineTimeNs = 31749,
Timing = new int[] { 0, 0, 0, 0 },
Term = new int[] { 0, 0 },
BlackLevel = 16
},
new ModeDef
{
Regs = Ov5647SensorRegs.Ov5647Mode7Regs,
NumRegs = Ov5647SensorRegs.Ov5647Mode7Regs.Count,
Width = 640,
Height = 480,
Encoding = 0,
Order = BayerOrder.BAYER_ORDER_GBRG,
NativeBitDepth = 10,
ImageId = 0x2B,
DataLanes = 2,
MinVts = 484,
LineTimeNs = 21165,
Timing = new int[] { 0, 0, 0, 0 },
Term = new int[] { 0, 0 },
BlackLevel = 16
}
};
}
}
37 changes: 37 additions & 0 deletions src/MMALSharp/Config/SensorDefs/Imx219SensorDef.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
using MMALSharp.Config.ModeDefs;
using MMALSharp.Config.SensorRegs;

namespace MMALSharp.Config.SensorDefs
{
public static class Imx219SensorDefs
{
public static SensorDef Imx219SensorDef = new SensorDef
{
Name = "imx219",
Modes = Imx219ModeDefs.ModeDefs,
NumModes = Imx219ModeDefs.ModeDefs.Count,
StopReg = Imx219SensorRegs.Imx219StopRegs,
NumStopRegs = Imx219SensorRegs.Imx219StopRegs.Count,

I2CAddr = 0x10,
I2CAddressing = 2,
I2CIdentLength = 2,
I2CIdentReg = 0x0000,
I2CIdentValue = 0x1902, // 0x0219 bytes reversed.

VFlipReg = 0x172,
VFlipRegBit = 1,
HFlipReg = 0x172,
HFlipRegBit = 0,

ExposureReg = 0x015A,
ExposureRegNumBits = 16,

VtsReg = 0x0160,
VtsRegNumBits = 16,

GainReg = 0x0157,
GainRegNumBits = 8 // Only valid up to 230.
};
}
}
Loading

1 comment on commit 56bb0b0

@techyian
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tracked against #124.

Please sign in to comment.