Direct injection is usually used for larger diesel engines and 2-stroke diesel engines, while indirect injection is usually used for smaller 4-stroke diesel engines.
The way 2-strokes and 4-strokes get air is also very different. In a 4-stroke diesel, just as in a gasoline engine, the inlet and exhaust ports are controlled by valves. But the much higher operating pressures and temperatures in diesel engines put more stress on diesel valves which are usually larger than those in gasoline engines. The intake valve passes only air so it is cooler than the exhaust valve which releases all the hot gases after combustion.
Valves in the diesel engine are usually parallel to the center-line of the engine.
Small 4-stroke engines usually have two valves per cylinder. One inlet and one exhaust.
This 2-stroke diesel engine lets air into the cylinder through inlet ports with no inlet valve. But its exhaust ports do have valves.
4-strokes and 2-strokes use the same system to control their valves.